Short answer: on a Mac keyboard Q sits directly left of W and directly right of Tab, so reaching for Cmd W or Cmd Tab can land on Cmd Q and quit the whole app.
macOS has no setting to turn Cmd Q off. You can move Quit to another shortcut per app in System Settings, use a browser's own warning, or add a guard that asks for a second press or a hold.
Three shortcuts you use all day share one corner of the keyboard:
Cmd W loses one tab. Cmd Tab loses nothing. Cmd Q loses the lot, and it is the one in the middle.
Quit Safari.It costs nothing and needs no download. The catch: the menu title includes the app name, so you repeat this for every app. Full steps are in how to disable Cmd Q on a Mac.
The browser comparison is in stop Cmd Q in Chrome, Safari and Arc.
Several small Mac apps add a delay or a second press to Cmd Q. Delay Quit Apps is free. QuitGuard is paid. SlowQuitApps is open source and has not been updated since 2020. SlowQuitApps alternatives compares them.
Still Dock guards Cmd Q in the apps you choose, in two styles:
Press twice, confirm or hold explains which suits you. Choosing Quit from the menu still works, and Still Dock itself always quits with one Cmd Q. Cmd Q protection is part of Still Dock Pro.
The same corner causes two smaller slips. Cmd W can close a window full of tabs when you meant one, and stop Cmd W closing all tabs covers the fixes. In the version from stilldock.com, Still Dock can ask before Cmd W closes a window and can stop Cmd Tab switching apps, for example during a game or on a child's Mac. See disable Cmd W and disable Cmd Tab.
No. Reopen the app and press Shift-Command-T in a browser to bring back recent tabs. Text typed into a form does not come back.
Not in System Settings: each app's Quit item has its own name, so each needs its own shortcut. A guard app covers all the apps you pick in one place.
Press twice adds one quick tap and hold adds a fraction of a second. Quit from the menu is never delayed.