Close all Safari tabs with a specific name

It appears to work (as it closes multiple tabs with that name, and no others), but it gives me the following error message:

error "Safari got an error: Can’t get item 4 of every window. Invalid index." number -1719 from item 4 of every window

EDIT: I came up with the following script and it appears to work. Can somebody tell me if they see any potentials or problems errors with it?

set closeTab to "Linguee" as string
tell application "Safari"
	close (every tab of window 1 whose name contains closeTab)
end tell

EDIT 2: It appears that only works if those tabs are in the most recently activated Safari window...

EDIT 3: If I put in multiple "tell window" lines it works (as shown below), but I don't always have the same amount of windows open and I'd rather keep this script as simple as possible. Is there a way to have AppleScript tell Safari to close tabs across all open windows?

set closeTab to "Linguee" as string
tell application "Safari"
	close (every tab in window 1 whose name contains closeTab)
	close (every tab in window 2 whose name contains closeTab)
	close (every tab in window 3 whose name contains closeTab)
end tell

EDIT 4: I think I came up with something that works across multiple windows and doesn't give any errors.

set closeTab to "Linguee" as string
tell application "Safari"
	set _W to a reference to every window
	
	repeat with W in _W
		close (every tab of W where the name contains closeTab)
	end repeat
end tell