The latest versions of most web browsers have implemented a feature to prevent javascript from closing current window or tab.
This method is only allowed to be called for windows that were opened by a script using the window.open() method. If the window was not opened by a script, the following error appears in the JavaScript Console: Scripts may not close windows that were not opened by script.
Same thing applies to Internet Explorer and Chrome but I couldn't find an official document for them about this feature to link here.
My question is "Why do browsers prevent javascript from closing current window unless that window was opened via a script itself? What types of attacks or abuse cases is this feature defending against?"