But if you're trying to close a window that you didn't want to open, you probably want the red button not the yellow one.
If what you're trying to do is move a page from its own window to another window, you can drag its tab. But that's not possible if you have "Show tab bar" disabled in the view menu, the tab bar will be hidden for windows with a single tab.
Alternate workaround if you find yourself accidentally opening things in a new window by accident frequently: instead of right clicking and picking from the menu, command-click on the link to open it in a new tab. If you have a 3-button mouse, middle click will do this as well.