The problem of controlling quantum stochastic evolutions arises naturally in several different fields such as quantum chemistry, quantum information theory, quantum engineering, etc. In this paper, we apply the recently discovered closed form of the unitarity conditions for stochastic evolutions driven by the square of white noise  to solve this problem in the case of quadratic cost functionals (cf. (5.5) below). The optimal control is explicitly given in terms of the solution of an operator Riccati equation. Under general conditions on the system Hamiltonian part of the stochastic evolution and on the system observable to be controlled, this equation admits solutions with the required properties and they can be explicitly described.