Optimized shutdown