How to enable confirmation alert before closing chrome tabs?

If you click "Warn before Quitting" in the Chrome menu on Mac it'll do the trick. It'll make you hold command + Q to quit. Not sure on PC.

This was huge for me because closing a tab, command + W is right next to close the whole freaking browser command + Q. Made that mistake too many times!

This is what it looks like on MacOS Sierra: enter image description here


If you close multiple tabs in your Chrome there is an alert box asking to "Close all the tabs?"

Yes Chrome closes the tab if you are pressing the X button without any confirmation and it can be quite annoying if you accidently close it in order to do so. You can press CTRL + SHIFT + T To restore your previous session of all your tabs.

You could also look for a Chrome extension such as Windows Close Protector


In my case the biggest problem is when I use ctrl-shift-W or ctrl-shift-Q. If you want to remap a shortcut:

  1. Go to chrome://extensions
  2. In the very bottom right, click keyboard shortcuts Keyboard shortcuts A
  3. Rebind Ctrl + Shift + W to something less annoying. In my case I bound it to open lastpass extension.

enter image description here

Also, FYI: Ctrl-Shift-T will reopen all your tabs


To prevent accidental closing of Google Chrome:

  1. Download and run NoClose (add it to the Startup folder if you want it to start with Windows).

  2. Press Ctrl+1 to enable/disable the close button for the currently active window.
    close button disabled

To prevent accidental closing of individual tabs:

  1. Install an extension that allows embedding custom JS to web pages. I used Page Modifier, but there are others available like JScript tricks and Custom JavaScript for websites.

  2. If you chose Page Modifier, create a new script and enter the following JS code from kbeezie.com:

    function PopIt() { return "Are you sure you want to leave?"; }
    function UnPopIt()  { /* nothing to return */ }
    
    $(document).ready(function() {
        window.onbeforeunload = PopIt;
        $("a").click(function(){ window.onbeforeunload = UnPopIt; });
    });
    
  3. Set the Applied to field to * so the script runs everywhere, and save it.
    confirm navigation from page

The script will only be executed on any new pages you visit thereafter. Already open tabs will need to be reloaded for the script to execute.

I haven't tested it extensively so it might not work for all web pages, but if you're good with code, you could probably tinker with it and fix the problems.


I choose to trick "myself" on this. Open chrome, pin the first tab. That will eliminate the X button from that first tab :)