Fix trying to close the same stream twice.