Graceful shutdown improvements
Merge pull request #111 from stuartwdouglas/master

Graceful shutdown improvements