gracefully shutting down server

fixes #13 
We maybe want to make the delays configurable.