If any window title of Safari contains x then

Oh, cool. No, as I understand it, "Window" means a window object, from OS/X's point of view. So the tabs don't count.

You may already have this macro, but if not, get it. It shows what Windows are available to KM at the moment: