Don’t re-close a closed output stream.

Fixes #1541 for 3.0.  Follow up to #1544.  Will merge when green.