Protect the clean-up code from exceptions
Merge pull request #4 from draftcode/protect_exception

Protect the clean-up code from exceptions