Call cleanup before throwing error. Fixes #40
Merge pull request #62 from krux/cleanup-onerror

Call cleanup before throwing error. Fixes #40