In System Settings > Keyboard Shortcuts > App Shortcuts, add the shortcut: app Safari, name "Quit Safari", command-option-Q. This will leave command-Q doing nothing, yet still allow you to quit. Repeat for other apps.
PS: and sometimes the name string is also dynamic "Navigate to the latest folder named XYZ", so you can't match at all!