moved graceful shutdown to new file