Gracefully shutdown the server