Fix: Allow stdout to drain before exiting (fixes #317)