This paper presents an optimal control strategy that can guide any initial random configuration of nanoparticles to a final structure of desired geometry, in minimum time. It employs a multi-resolution view of the dynamically evolving configurations of nanoparticles, which are described through the Adaptive Finite State Projection (AFSP) approach introduced in Part 3 of this series. External charges, attracting or repelling the nanoparticles, are the controls, whose location and intensity are determined by the optimality conditions of the optimal control strategy. To ensure analytic consistency of the parametric sensitivities, during the computation of the optimal controls, and thus guarantee the optimality of the resulting control policy, a priori determination of enlarged constant projection spaces is shown to be essential. A case study illustrates the use of the proposed optimal control strategy and illuminates several of its features, such as: superiority over a static optimal solution; evasion of kinetic