Fix exit codes

The previous implementation would exit successfully regardless of any error.
Merge pull request #1 from stephenmathieson/fix/exit-codes

Fix exit codes