Capture exit code

fixes #1