main: in both exception handlers, explicitly flush stdout before emitting bytes onto stderr, since the two aren't connected any longer.