An Online Computation Approach to Optimal Finite-Horizon Control of Nonlinear Stochastic Systems