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 9
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!
-
70I cannot understand why they would put that option in the Chrome menu rather than putting it in preferences. Anyway, thanks for this, I would not have thought to look in that menu.SaganRitual– SaganRitual2014-12-11 19:00:32 +00:00Commented Dec 11, 2014 at 19:00
-
-
4Yeah, this is a setting, put it there. What nonsense.user232846– user2328462015-03-08 21:30:22 +00:00Commented Mar 8, 2015 at 21:30
-
12
-
9Where exactly is this option? I can't find it under the hamburger icon, nor in Settings. Not sure if it's been moved in Chrome v45 for Windows.Danny Beckett– Danny Beckett2015-09-16 20:27:50 +00:00Commented Sep 16, 2015 at 20:27
-
7So they just added this feature for Macs only? Not only that, are there only Mac users on Superuser?Asaf– Asaf2016-04-15 10:47:22 +00:00Commented Apr 15, 2016 at 10:47
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
-
Extension is working when closing browser. I need an option available in opera browser. I think chrome may not have such option. anyway thanks for your answer.Kumar V– Kumar V2014-01-21 11:16:35 +00:00Commented Jan 21, 2014 at 11:16
-
-
5This Extension does not work anymore. Pig Toolbox does not work, too. So after Chrome Toolbox was kicked "Doube-click to close" and "multiple-close"-warning are not possible anymore. This really sucks.mgutt– mgutt2014-08-30 00:01:27 +00:00Commented Aug 30, 2014 at 0:01
-
3Click the 'Chrome' button in the top left of your screen when in Chrome and then choose the 'Warn Before Quitting' option.jimmyplaysdrums– jimmyplaysdrums2016-02-03 03:38:55 +00:00Commented Feb 3, 2016 at 3:38
-
You can restore your previous tabs... when you're not in incognito mode...Adam Plocher– Adam Plocher2017-02-26 23:30:48 +00:00Commented Feb 26, 2017 at 23:30
-
Please update the link.Donald Duck is with Ukraine– Donald Duck is with Ukraine2017-03-12 09:31:10 +00:00Commented Mar 12, 2017 at 9:31
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
-
2You, sir, are my hero of the day. I accidentally hit Ctrl+Shift+W at least once a week, and Ctrl+Shift+T never restores the windows to their original position (or monitor!).Mike Strobel– Mike Strobel2017-03-30 20:07:22 +00:00Commented Mar 30, 2017 at 20:07
-
-
1This is savior! Thanks. Keyboard shortcuts option can now be accessed by opening burger menu on the left side.Himanshu– Himanshu2019-03-01 07:13:25 +00:00Commented Mar 1, 2019 at 7:13
-
You can also go to
chrome://extensions/shortcutsmwfearnley– mwfearnley2024-08-30 13:13:32 +00:00Commented Aug 30, 2024 at 13:13
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.
-
It works but it pops up for every tab, it would get annoying fast.GinKin– GinKin2015-02-26 21:13:50 +00:00Commented Feb 26, 2015 at 21:13
-
-
@GinKin Isn't that the idea? A confirmation popup before closing any tab?Vinayak– Vinayak2015-02-26 21:16:40 +00:00Commented Feb 26, 2015 at 21:16
-
Not every tab, just when pressing the X to close the window, like how it works on Firefox.GinKin– GinKin2015-02-26 21:19:00 +00:00Commented Feb 26, 2015 at 21:19
-
@GinKin You mean when multiple tabs are open and you're closing Chrome?Vinayak– Vinayak2015-02-26 21:21:31 +00:00Commented Feb 26, 2015 at 21:21
-
2Exactly. (15 characters to comment)GinKin– GinKin2015-02-26 21:24:03 +00:00Commented Feb 26, 2015 at 21:24
I choose to trick "myself" on this. Open chrome, pin the first tab. That will eliminate the X button from that first tab :)
-
2It does not prevent Ctrl-W from working... (ctrl-shift-t works for unclosing individual tabs...)Gert van den Berg– Gert van den Berg2016-07-18 10:16:33 +00:00Commented Jul 18, 2016 at 10:16
I believe the closest thing to this feature in stock Chrome is "continue where I left off" under the "On startup" section in settings.
-
Yes. we can but i wrongly closed a payment page tab. so i can not reopen it as it will submit the payment second time.Kumar V– Kumar V2014-01-21 11:17:42 +00:00Commented Jan 21, 2014 at 11:17
-
-
@kumar_v This would be a very bad payment site.mgutt– mgutt2015-01-24 11:03:01 +00:00Commented Jan 24, 2015 at 11:03
-
1Continue where you left off does not work when you have multiple Windows open. (I had a case where I accidentilly hit Ctrl-Shift-w instead of Ctrl-w and for some reason, Ctrl-shift-t only opened the same tab multiple times, instead of recovering the window like normally)Gert van den Berg– Gert van den Berg2016-07-18 10:15:24 +00:00Commented Jul 18, 2016 at 10:15
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.
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.
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/
-
So, standard question - why downvote without any comment? I think my answer is elaborate enough. Clicked wrong button? Or did you happen to own one of the software I described above? :PRoland Pihlakas– Roland Pihlakas2022-01-06 15:52:51 +00:00Commented Jan 6, 2022 at 15:52


<script>window.onbeforeunload = function() { return "You are closing all tabs!"; }</script>