A method of on-line constructing an optimal feedback control for linear and nonlinear systems is proposed. The idea of closed-loop solution is based on constructing a realization of optimal feedback in any concrete control process under unknown but bounded disturbances. The realization of the algorithm of closed-loop solution is oriented on fast corrections of optimal open-loop control subject to small variations of initial state. This is possible due to storage a small amount of additional information allowing to avoid the complete integration of primal or adjoint system.