What you want to do is undesirable for the user.
If a user loads your page and you as a webmaster decides that the main browser needs to close, then they will likely get seriously annoyed if you succeeded.
Window history and such, gone.
Please explain EXACTLY why you want this. For example if you need to log someone out use location.replace('logout.php)` and have that page log them out
There are hacks that I personally wish would be fixed - in this exact duplicate here: How can I close a browser window without receiving the "Do you want to close this window" prompt?