Flush output streams before invoking external commands