Improved shutdown procedure