A real-time optimization technique is discussed concerning state-feedback control of general nonlinear systems. An optimal state-feedback law is determined so that a receding-horizon performance index with a moving terminal time is minimized. It is shown that the receding-horizon control problem can be converted to an initial-value problem for an ordinary differential equation that can be solved numerically without recourse to iterative methods. The proposed solution technique is applied to a control experiment on a simplified space-vehicle model. The penalty-function approach is employed in the performance index so that the space-vehicle model attains the objective state, avoiding an obstacle. The model is controlled successfully at the sampling frequency of 30 Hz in the hardware experiment.