simplify atexit and fflush-on-exit handling