Logout is not happening on Browser/Tab close

Hi fellas,

we are facing an issue when we try to logout of single page react application , below is the code used to call logout function. let me know if you need further info.

const { logout } = useAuth0();
useEffect(() => {
const handleTabClose = (event: { preventDefault: () => void; returnValue: string; }) => {
localStorage.removeItem(‘id_token’);
logout();
event.preventDefault();
console.log(‘beforeunload event triggered’);
return (event.returnValue = ‘Are you sure you want to exit?’);
};

   window.addEventListener('beforeunload', handleTabClose);
    return () => {
        window.removeEventListener('beforeunload', handleTabClose);
    };
}, []);