Fix crash that happened when commands failed
Merge pull request #40 from jonbinney/cleanup-bug

Fix crash that happened when commands failed