there are many articles for window and tab close detection, however, since the newest browser published, those codes since not working anymore. webkit-page-cache-ii-the-unload-event is an article for webkit browsers. It use onPageHiden() to detect the leave page event, however, it seems no longer work in chrome. Also, if I just close the browser, It won’t do anything also.
How I can trigger an event when I not only close the tab but also close the browser?
You can’t. You can detect when a page gets closed if the browser allows you; you can’t tell why it was closed.