We model the dynamics of a closed quantum system brought out of mechanical equilibrium, undergoing a non-driven, spontaneous, thermodynamic transformation. In particular, we consider a quantum particle in a box with a moving and insulating wall, subjected to a constant external pressure. Under the assumption that the wall undergoes classical dynamics, we obtain a system of differential equations that describes the evolution of the quantum system and the motion of the wall. We study the dynamics of such system and the thermodynamics of the process of compression and expansion of the box. Our approach is able to capture several properties of the thermodynamic transformations considered and goes beyond a description in terms of an ad-hoc time-dependent Hamiltonian, considering instead the mutual interactions between the dynamics of the quantum system and the parameters of its Hamiltonian.