How can I avoid losing tabs in Firefox when closing one of multiple windows?
You can go to Firefox menu->Preferences (or Options, can't remember which), Tabs tab, and check "Warn me when closing multiple tabs." However, even on Firefox app quit, if multiple tabs are open, you will still be warned.
If you close Firefox often enough that this is annoying, you can simply remember to go to Firefox menu->History->Recently closed windows to see and reopen recently closed windows. You can do the same thing via Ctrl+Shift+N, I believe (if that's not the right shortcut, the right one should be printed to the right of the most recently closed window.)