If you’re like me, you constantly have a ton of tabs open—articles to read later, sites you want to browse, research for a project, etc. And if you use Safari, you’ve likely nuked them all by accidentally pressing the wrong keystroke.
Like in other Mac apps, pressing Command-Q will quit the entire app without warning. While other browsers have the option to warn before quitting so you can cancel the action, Safari doesn’t. And what’s worse, the keystroke is right next to the common Close Tab (Command-W), Save (Command-S), and Select All (Command-A) keystrokes. I can’t tell you how many times I’ve accidentally quit the app and lost all of my tabs when I really wanted to do something else.
It’s so infuriating that I had started to prefer using Chrome, which does warn you if you press the Command-Q button. But then I discovered a feature baked into macOS that changed my tune: App Shortcuts. It’s a feature that lets you change the system-defined shortcut in an app and made my Safari experience 100 times better. Here’s how it works.
Go to System Settings (Ventura) or System Preferences (Monterey and earlier)

Foundry
Head over to System Settings (System Preferences in macOS Monterey and earlier) and click the Keyboard tab.
Create an App Shortcut

Foundry
Select Shortcuts and App Shortcuts and press the + symbol to add a new shortcut.
Name your shortcut Quit Safari

Foundry
Select Safari from the drop-down menu, name the command “Quit Safari” (without the quote marks; it needs to be exact) and choose a keystroke other than Command-Q. I used Shift-Command-Q to avoid any accidental triggers, but anything will work.
A Macworld reader points out another setting that would have helped me as well. In the General Preferences, there’s a “Safari opens with” drop-down menu that defaults to “A new window.” You can change that to “All windows from last session” which will restore closed tabs when quitting or restarting the app. I still prefer to change the quit command so I don’t need to reload everything but it’s definitely useful.
I’ve lost track of how many times I accidentally pressed Command-Q before I did this and would have surely added many more without it. It’s a simple change that I should have thought of years ago—and it’s made me love Safari again.