Abstract: We consider a non-standard optimal control problem in which the state trajectory terminates once a stopping condition is satisfied. By using a finite-dimensional discretization of the control space, a class of approximate problems corresponding to this optimal control problem is constructed. Each of these approximate optimization problems can be viewed as a non-linear mathematical programming problem, and we develop a numerical scheme for computing the relevant gradients. On this basis, each approximate problem can be solved using existing gradient-based optimization techniques. Several important convergence results are provided to justify this approach. For illustration, our method is implemented to solve a practical aeronautical control problem.