I was reading Mac Format this morning and read about an application called Taboo that stops you from accidentally closing Safari windows with multiple tabs open, or even quitting Safari when there are multiple tabs open in a window.
This is one of the few things that I find annoying about Safari, although I still use it most of the time in preference to any other browser. I downloaded Taboo from www.ocdev.com and installed it. You have to quit Safari completely before you can install it, but that wasn’t a problem.
Having installed it, I can confirm that it does exactly what it’s supposed to. I opened 2 tabs and tried to close the window both with Cmd-W and clicking on the red button in the title bar and both times it popped up with a warning about trying to close a window with multiple tabs open.