4 Handy Ways to Prevent Google Chrome From Closing Accidently

Living on a browser has become a standard among people nowadays. Most of the work we do revolve around online services resulting in us having endless tabs open throughout the day. Sometimes, however, you accidentally hit the close button and before you know it, all your opened tabs in Chrome are trashed. Hence, we bring you a couple of nifty ways to prevent that from happening – by showing a warning message when closing a tab or by disabling the close button.

#.Prevent Chrome from Accidentally closing using a Website.

warn message when closing chrome tab - Gtricks

Probably the easiest way to prevent Chrome from closing accidentally is to keep a warning website open along with your other tabs. As soon as you tap the close button, Chrome will pop a warning window about terminating the browser, you can either continue or stay by clicking the respective options.


Pro Tip: Pin this website, so that every time you fire up the Chrome browser, it will automatically start loading.

#.Disable the close button temporarily on Windows.

No close button in Chrome

By following a couple of steps, you can as per your demands disable the close button of any application on Windows. To do so,

  1. Head over to this website and download the “NoClose.exe” file.
  2. Place it inside your startup folder.
  3. Run the “Noclose.exe” executable.
  4. You’re done. Now whenever you’re in Chrome or any other Desktop software, press “Ctrl+1” together to disable the “X” button. To enable, press the combination again. This works in most of all any other windows software out there.


Related: Enable Right Click on Chrome

#. Make use of Chrome’s own “Continue where you left off” setting.

continue where you left Chrome

Google offers a useful setting in Chrome itself that reopens all the tabs you had while you terminated the browser. To activate it, head over to Settings and click the “Continue where you left off” radio button. Now every time, you restart Chrome, you’ll have all the last session’s tabs load up automatically. Though, we won’t recommend this if you’ve a slow system or connection.

#. Insert a custom JavaScript code to get a warning from individual tabs on Chrome.

If you want a warning from each individual tab, a JavaScript code will need to be implemented on your browser. Don’t worry, it’s not that intimidating. First of all, download this free extension. Next up, hit that new icon on the top right corner and now fill the fields as shown below.


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; });

Hit “Save” and you’re done! Now, you’ll get a confirmation message from each tab when you click the close button. However, this can be frustrating if you’ve a lot of tabs open.

So, those were some of the ways you can make use of to prevent Chrome from closing accidentally, hope it helped. Let us know if we missed something or you’re stuck somewhere in the comments section down below.

Also see: Best of Chrome’s new tab extensions

Did you find this article useful -

Filed under Google Chrome. Posted by Abhishek and last updated on July 27, 2017.

Leave a Comment:

Your email address will not be published. Required fields are marked *


Doesn’t work. Nothing happens and tab is closing as usual.

I’ve gotten Page Modifier installed and I pasted in your script and put “*” in the “Applied to:” field, but I don’t get a pop-up. It still allows me to close tabs without confirmation. I’ve turned off all other extensions and rebooted Chrome once just to be sure, but it’s still not working.

Any thoughts?

    Sorry to hear Johannes that it did not work. I think the culprit are the quotes in the script. Can you please paste the script first in a notepad and then in the extension and see if that works?

Changing the double quotes to single quotes seems to have fixed it. The working script looks like this:

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; });

Get Google Updates

Every Sunday, we send out "Google This Week" newsletter which covers all the latest and important updates from Google. First, we curate information from authentic and verified sources and then write the newsletter in an easy to understand format with images and summary for each update. View Sample ›

Join 9000+ subscribers following their favorite company in a simpler and easier way. Join Now ›