Fix some issues with graceful shutdown
Merge pull request #94 from stuartwdouglas/graceful

Fix some issues with graceful shutdown