want to do some ajax on browser/tab closed event

want to do some ajax on browser/tab closed event

Hello Team,

I want to do some ajax coding on Tab/Browser close. Is any way to identify the browser close and get it work as need.

I have tried some code but not able to get it success.

$(window).bind( 'beforeunload' , function (){

         return '>>>Before You Go<<<<<<<< \n Your custom message go here' ;

     });

Its work but not able to customize, If any reference link so it will really helpful.

Thank You
Jay