jquery .on('unload',..); was not reliable working for me. i switched over to use beforeunload. just make sure you are not returning anything, or the user will get a "are you sure to leave the page"-popup.
<script type='text/javascript'>
$(window).on('beforeunload', function(){
console.log("beforeUnload event!");
});
</script>