Don’t re-close a closed output stream.

Fixes #1541 for 2.99.
Merge pull request #1544 from rspec/fix-1541-for-2-99

Don't re-close a closed IO (for 2.99)