Thermodynamics and the energy criterion for stability