The stringent timing and reliability requirements in mission-critical applications require a detailed statistical characterization of the latency. Teleoperation is a representative use case, in which a human operator (HO) remotely controls a robot by exchanging command and feedback signals. We present a framework to analyze the latency of a closed-loop teleoperation system consisting of three entities: HO, robot located in remote environment, and a Base Station (BS) with Mobile edge Computing (MEC) capabilities. A model of each component of the system is used to analyze the closed-loop latency and decide upon the optimal compression strategy. The closed-form expression of the distribution of the closed-loop latency is difficult to estimate, such that suitable upper and lower bounds are obtained. We formulate a non-convex optimization problem to minimize the closed-loop latency. Using the obtained upper and lower bound on the closed-loop latency, a computationally efficient procedure to optimize the closed-loop latency is presented. The simulation results reveal that compression of sensing data is not always beneficial, while system design based on average performance leads to under-provisioning and may cause performance degradation. The applicability of the proposed analysis is much wider than teleoperation, for systems whose latency budget consists of many components.