According to w3school The unload() method was deprecated in jQuery version 1.8 and removed in version 3.0. and these code not worl also
$(window).unload(function(){
alert("Goodbye!");
});
any new method for doing that task please help me this is example code i am building live chat application when user close browser update value to database