Flush std{in,out,err} before closing it. Fixes #1074011.
Will backport to 2.4 and 2.3.
diff --git a/Misc/NEWS b/Misc/NEWS
index 7753df5..4f41e44 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
 Core and builtins
 -----------------
 
+- Bug #1074011: closing sys.std{in,out,err} now causes a flush() and 
+  an ferror() call.
+
 - min() and max() now support key= arguments with the same meaning as in
   list.sort().