Way to detect other browser tabs on same app before close

Thanks for all the replies, sorry not to have commented until now. @znewsham is right, I was trying to only logout the user if they had no other tabs open. The usecase was that the user opened several tabs to handle work in the app. Logging them out when they closed one of these tabs left a very bad experience.

My solution here is to move away from my initial idea and use more of an “idle time” approach. If a user has been inactive for a certain amount of time, show a modal about being logged out. Trying to work around my initial idea with counts, local or session storage seemed quite flaky and hard to get right