tests._common now captures output even if SystemExit is caught.
Moved error handling from events to main.

This makes the plugin code match the unitest2 plugins branch more
closely.
Also, sys.exit is safer to call from the main module.