Exit code

Correct the exit code to be a simple value, rather than two or three separate values stuffed into a single integer.

Closes issue #2794.

My reading of the [Windows docs](http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/exit.mspx?mfr=true) is that the test I've added should work on Windows as well.