How to enable confirmation alert box option before closing opened tab in chrome browser? Need to change setting? I couldn't find any such options in setting window.
9 Answers
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!
- 44,080
- 1,601
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
- 441
In my case the biggest problem is when I use ctrl-shift-W or ctrl-shift-Q. If you want to remap a shortcut:
- Go to chrome://extensions
- In the very bottom right, click keyboard shortcuts

- Rebind Ctrl + Shift + W to something less annoying. In my case I bound it to open lastpass extension.
Also, FYI: Ctrl-Shift-T will reopen all your tabs
- 259
- 1
- 3
- 8
To prevent accidental closing of Google Chrome:
Download and run NoClose (add it to the Startup folder if you want it to start with Windows).
Press Ctrl+1 to enable/disable the close button for the currently active window.

To prevent accidental closing of individual tabs:
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.
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; }); });Set the
Applied tofield to*so the script runs everywhere, and save it.

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.
- 22,532
- 10,885
I choose to trick "myself" on this. Open chrome, pin the first tab. That will eliminate the X button from that first tab :)
- 39
I believe the closest thing to this feature in stock Chrome is "continue where I left off" under the "On startup" section in settings.
- 31
There is a "Chrome Toolbox" extension which is supposed to handle this, but it is no longer supported. So what I did on Mac OS is to change keyboard shortcut for quitting Chrome "Cmd-Q" to something which doesn't trigger accidentally (e.g. Ctrl-Cmd-Shift-Q) so I am sure I will never press it accidentally again.
To change this shortcut goto System Preferences > Keyboard > Shortcuts > App Shortcuts. Click on + sign, from App dropdown select "Google Chrome.app", for Menu Title type "Quit Google Chrome" and for shortcut, press a complex key combination.
- 283
- 2
- 9
An extension or a third-party software program to achieve this sounds like too much work. Some answers apply only to Mac while others requires you to add script runners in Chrome to inject a certain script in all pages which again causes a problem where the confirmation box is shown for all tabs.
I believe the need of most users here is that they want to protect the whole window from closing at once and not each tab. I have created a simple static HTML page with a bit of JavaScript that makes a confirmation box appear when the whole Window is about to close.
You can find the HTML page here (hosted on JSBin) : http://jsbin.com/pejejib
How to use it? The only requirement is that you have the page opened in Chrome always during a session so that whenever you have clicked on the "X" button or the keyboard shortcut to close the Chrome window, the script in the page I've created is run and asked for confirmation.
- You can bookmark it and open it as per your requirement - when you are about to go for a long browsing session and you want to prevent such accidents then this is the best option.
- If you don't want to bother opening it each time you open Chrome, you can go to the page > right click on the tab > pin tab. Now whenever your close the browser the pinned tab will automatically open the next time you open it.
- OR set it as one of your startup-pages in Chrome. (best option if you use startup-pages)
The benefits of this is:
- No installation or extension is required, this is just a simple HTML page
- Doesn't display the confirmation box multiple times i.e each for all tabs.
- You can create your own fork and use it the way you like
For transparency, this is the JavaScript code in the page -
window.onbeforeunload = function(e) {
var dialogText = 'Are you sure you want to close the Window?';
e.returnValue = dialogText;
return dialogText;
};
Yes, that's all! Simple and straightforward.
- 163
For Window-level confirmation I used software listed at https://www.raymond.cc/blog/prevent-program-closing-disabling-close-button/
Summary of the software listed at the above link:
- NoClose (did not work for me)
- WinTopMost (expensive, did not try)
- Actual Window Guard (not free, but has a trial and works, even on Chrome, can be configured with various process and or window filters)
- Actual Window Manager (same as above, but more expensive with more additional features)
- NoVirusThanks Process Protector (no trial, did not try)
So my choice was https://www.actualtools.com/windowguard/
- 159
- 1
- 1
- 8

