Issue #13444: When stdout has been closed explicitly, we should not attempt to flush it at shutdown and print an error.
This also adds a test for issue #5319, whose resolution introduced the issue.
A
Antoine Pitrou committed
d7c8fbf89e751d43c56de0071702d2578676d0a1
Parent: fb36b3f