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.
-
1I cannot post an answer because of reputation but this seems like a viable solution: https://www.cnet.com/how-to/how-to-prevent-closing-multiple-tabs-in-chrome/ Just keep the following link open in open in Chrome: http://www.maki-chan.de/preventclose.htm Or create a custom tab with the code and set it as home page: `` – Alex Kamburov Feb 13 '17 at 13:17
-
3Those who want to follow the official um...how's a nice way to put it...never mind...thread, can do so here: https://bugs.chromium.org/p/chromium/issues/detail?id=147 – Kev Apr 11 '17 at 05:09
-
Also another Chrome extension: https://github.com/gabrielmaldi/chrome-lock-tab – aderchox Nov 12 '22 at 13:16
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!
- 41,734
- 35
- 103
- 130
- 1,591
- 2
- 9
- 3
-
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 Dec 11 '14 at 19:00
-
4
-
10
-
It's probably in the menu bar because it's a global setting. All the other settings are per profile. Since you can have more than one profile I guess it makes sense to have this setting for all profiles at once, hence the menu bar. – Jeroen Jul 14 '15 at 12:58
-
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 Sep 16 '15 at 20:27
-
The setting is actually based in the preferences menu and not the usual 'settings' place. – Oliver Dixon Oct 23 '15 at 20:27
-
1Not only is the placement of this setting unusual (it's in the **Chrome** menu in the top left of the window on OS X) but it's something you would expect to be enabled by default. – Dennis Oct 27 '15 at 22:01
-
7So they just added this feature for Macs only? Not only that, are there only Mac users on Superuser? – Asaf Apr 15 '16 at 10:47
-
-
For chrome 65 on mac os sierra, if you click the "Chrome" entry on the menu bar (the first entry after the apple), the second to last entry on the drop down list says "Warn before Quitting". It doesn't look like a checkbox type of setting, but it is. Click it, close the menu, and go back and now you'll see it's checked- – chrismarx Apr 17 '18 at 15:48
-
Must only be for Mac. For Windows, the command to close the app is `ALT+F4`. No way to confuse the two. Plus it always asks on Windows - actually no way to turn it off (that I know). – Chloe Aug 31 '18 at 00:31
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
- 2,473
- 10
- 29
- 45
- 441
- 3
- 6
-
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 Jan 21 '14 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 Aug 30 '14 at 00:01
-
3Click the 'Chrome' button in the top left of your screen when in Chrome and then choose the 'Warn Before Quitting' option. – jimmyplaysdrums Feb 03 '16 at 03:38
-
You can restore your previous tabs... when you're not in incognito mode... – Adam Plocher Feb 26 '17 at 23:30
-
-
This page pinned or opened in your browser window makes sure that you see a confirmation box whenever the complete window is being closed - http://jsbin.com/pejejib - just bookmark the page and open it every time you start a session or maybe set it as a start-up page so you do not have to bother clicking on a bookmark each time you open your browser. – Deepak Kamat May 23 '17 at 06:19
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
- 249
- 1
- 3
- 8
-
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 Mar 30 '17 at 20:07
-
1This is savior! Thanks. *Keyboard shortcuts* option can now be accessed by opening burger menu on the left side. – Himanshu Mar 01 '19 at 07: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.
- 21,399
- 46
- 64
- 121
- 10,625
- 10
- 54
- 89
-
-
@GinKin Isn't that the idea? A confirmation popup before closing any tab? – Vinayak Feb 26 '15 at 21:16
-
Not every tab, just when pressing the X to close the window, like how it works on Firefox. – GinKin Feb 26 '15 at 21:19
-
@GinKin You mean when multiple tabs are open and you're closing Chrome? – Vinayak Feb 26 '15 at 21:21
-
2
-
@GinKin You can use [NoClose](http://www.donationcoder.com/Software/Skrommel/#NoClose) for that. It's an AutoHotkey script that enables/disables the close button of the currently active window when you press `Ctrl`+`1`. – Vinayak Feb 26 '15 at 21:39
-
-
-
It's so strange that NoClose works with everything other than chrome... With admin rights of course. – GinKin Feb 26 '15 at 22:47
-
Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/21480/discussion-between-vinayak-and-ginkin). – Vinayak Feb 26 '15 at 22:48
-
-
-
I choose to trick "myself" on this. Open chrome, pin the first tab. That will eliminate the X button from that first tab :)
- 39
- 1
-
2It does not prevent Ctrl-W from working... (ctrl-shift-t works for unclosing individual tabs...) – Gert van den Berg Jul 18 '16 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.
- 31
- 2
-
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 Jan 21 '14 at 11:17
-
-
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 Jul 18 '16 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.
- 263
- 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
- 1
- 10
For Window-level confirmation I used software listed at https://www.raymond.cc/blog/prevent-program-closing-disabling-close-button/
- 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/
- 127
- 1
- 7
-
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? :P – Roland Pihlakas Jan 06 '22 at 15:52

