The task of finding optimal protocols that minimize the energetic cost of thermodynamic processes of long yet finite duration $\tau$ is a pressing one. We approach this problem here in a rigorous and systematic fashion by means of the adiabatic perturbation theory of closed Hamiltonian quantum systems. Our main finding is a $1/\tau^2$ scaling of the excess work for large $\tau$ in gapped systems. This result is at odds with the asymptotic $1/\tau$ prediction of the geometric approach to optimization, which is predicated on the slow evolution of open systems close to canonical equilibrium. In contrast, our approach does not lead to an obvious geometric interpretation. Furthermore, as the thermodynamic work does not depend on how an isolated quantum system is split into a system of interest and its environment, our results imply the failure of the geometric approach prediction even for open systems. Additionally, we provide alternative optimization procedures, both for slowly-varying processes described by adiabatic perturbation theory and for weakly-varying processes described by linear response theory. Our findings are benchmarked and confirmed through the application to the driven transverse-field Ising chain.