Flush std{in,out,err} before closing it. Fixes #1074011.
Will backport to 2.4 and 2.3.
2 files changed