Updated to stop gracefully