add onStop event function for shutting down the server