You can achieve the operation by trapping the browser close event programmatically using the below steps:
1. Create an instance of the ScriptManager as:
<asp:scriptmanager id="ScriptManager1" runat="server" enablepagemethods="true" xmlns:asp="#unknown" />
2. Subscribe to the unload event of the body tag of the ASP.NET page
<body onunload="HandleClose()">
</body>
3. HandleClose function is placed within the Head section of the page as
<script language="javascript" type="text/javascript">
function HandleClose()
{
alert("Killing the session on the server!!");
PageMethods.AbandonSession();
}
</script>
4. On the server side, define the AbandonSession method and add to it the WebMethod attribute.
[WebMethod]
public static void AbandonSession()
{
HttpContext.Current.Session.Abandon();
}