Implemented graceful shutdown of mysql