add shutdown hook
Merge pull request #451 from baev/shutdown-hook

Add shutdown hook