gracefully shutting down server

fixes #13