Flush stderr/stdout on exit to prevent errors on some Linux systems