core: flush stdout before exiting

On Blue Gene/Q, buffers are not flushed by exiting with a
non-zero code.

Suggested-by: Ray Loy <rloy@alcf.anl.gov>
Signed-off-by: Sébastien Boisvert <boisvert@anl.gov>