Automatically close browser tab after opening x amount of new ones

I have an open source shiny server where a user can open up any x number of tabs in their browser.

When they open a 5th tab of Shiny I want it to automatically close the 1st tab and so on where every 5th tab it closes the least recent tab.

Is there any global variable that would allow me to access the sessions of the same browser's windows by the same user?

Something like user$session$1 or something where on the fifth instance of shiny being open I could make user$session$5 close out user$session$1