defaults write NSGlobalDomain NSUserKeyEquivalents
'{"Quit Safari" = "@Q"; "Quit Mail" = "@Q";}'
[That should be one long line with a space after the NSUserKeyEquivalents word]
From now on, Command-Q will "beep" and only Command-Shift-Q will quit the application. A very similar hint tells you how to handle keys like Command-Option-.
You may also use Safari's defaults to change this, but I prefer this "global" way to have these special keys all together in one place. Unfortunately the menu is NOT named simply "Quit" but "Quit Safari," e.g., so you have to enter one extra entry for all apps in question.

