Error-proof beforeShutdown.