title: GWT:How to close the session on closing the browser
body: <p>In my GWT application i am trying to clear the session if browser closed by user .</p>
  
  <p>what i am doing is on closing Handler calling the rpc which invalidate the session,
  but the rpc call never happened and browser get closed.
  if there's any other solution for this</p>
  
  <pre><code>  Window.addWindowClosingHandler(new ClosingHandler(){
  
          @Override
          public void onWindowClosing(ClosingEvent event) {
  
              signOut();
          }
  
          });
  
    public void signOut() {
      rpcService.signOut(new AsyncCallback&lt;String&gt;(){
  
          @Override
          public void onFailure(Throwable caught) {
          }
  
          @Override
          public void onSuccess(String result) {
  
              History.newItem("login");
          }});
  }
  
     public String signOut(){
      session = request.getSession();
      session.invalidate();
      return "loggedout";
  
  }
  </code></pre>