Chrome has a great feature aptly named, "Warn Before Quit". It's enabled by choosing the word "Chrome" in the Mac Menu and then select "Warn Before Quit" in that dropdown.
It's been a life saver. As I use the great native app switcher shortcut "CMD+Tab" countless times every minute of every day to switch between apps. Unfortunately Tab is directly next to Q. So if one clicks CMD+Q it quits and app vs CMD+Tab which switches an app. In most apps this isn't too much of a big deal, since most Mac apps where you are entering content for instance will ask if you want to save the document before quitting. However of course saving a browser wouldn't make sense.
If you only have one tab open and are just surfing, you can simply reopen the browser, no big deal. However most of us have countless tabs open at once, meaning that mistaken CMD+Q vs CMD+Tab will make you lose all your tabs as well as potentially tabs you've entered content to which is now lost.
Warning when closing certainly shouldn't be default, but having an option like Chrome to warn would be wonderful. To note with Chrome if you enable that setting and press cmd+q mistakenly it will immediately popup saying hold CMD+Q to Quit. Meaning if it was a mistake you have a second to let go without losing any of your tabs, or if you hold it down within a second it will close all tabs like normal.
Also I know you can customize shortcuts for apps in System Preferences but don't believe that allows you to have cmd+q work normally after an extended hold like above, as certainly wouldn't want to have a custom keyboard shortcut for quitting Safari in particular.
Thank you for the suggestion!
This would be a Safari feature, not part of the WebKit rendering engine. Please send Safari bugs and enhancements requests via <https://bugreport.apple.com>.
That said, there are two existing features that help with this scenario:
1. In macOS General preferences, you can choose to have windows preserved across application relaunches.
2. Even if that's disabled, Safari has a menu item in History menu to re-open all windows from the previous session.