You don't mention how your security works. If you are using standard Cookie authentication or Session then simply do not persist the cookie. The cookie expires when the browser is close.
Cookie are scoped to the browser instance so there is not way to do the same when a tab is closed.
Keep in mind, this is well-known information if you've done any research then you should have come across this fact.