Gracefully closing MySQL connections when asked to leave