Merge pull request #229 from fragmer/master

Fixed a couple shutdown issues.