Fix #76 avoid possible thread leak on shutdown
Merge pull request #77 from johannesherr/dev

Fix #76 avoid possible thread leak on shutdown.  Thanks.