Fix exception being raised at end of batch mode

Also, move responsibility for exit() up into the main loop, keeping
things simpler and reducing the number of arguments needed by the
test-runner coroutine.