flush stdout/stderr after process exits

this fixes a race with quickly printing-and-exiting processes