On my Django site, I want to logout from the site automatically when I close the tab or browser. I mean when I close the site by closing the tab instead of using logout button, after entering the URL again, I want to see that the user has already logged out from the site to force the user to enter username and password again. 

Is there a way to handle closing the tab in JQuery? 

Thank you in advance.

Edit: onunload & onbeforeunload events cause to logout the user when also reloading the page.