Improved shutdown process.