title: GWT CloseHandler not calling RPC method
body: <p>I have a GWT application that registers a CloseHandler for the CloseEvent.  This handler calls the logout() method in another class, which does some cleanup and calls an RPC method to log the user out of the underlying server application (the GWT application is a client with web server being middle tier).</p>
  
  <p>Here is the code for the CloseHandler:</p>
  
  <pre><code>Window.addCloseHandler( 
      new CloseHandler&lt;Window&gt;() {
      @Override
      public void onClose( CloseEvent&lt;Window&gt; event ) {
              MainPresenter main = Client.this.context.getMainPresenter();
  
              if (main != null) {
   System.out.println("calling main.logout()..." );
                  main.logout();
   System.out.println("back from logout()..." );
              }
          }
      });
  </code></pre>
  
  <p>Here is the code for the logout() method:</p>
  
  <pre><code>public void logout() {
  System.out.println("in logout()..." );
      /*
       * This callback method likely will not be executed because this
       * logout method is going to be called as the browser window is
       * closing.  Consequently, the RPC call will not return.  But if it
       * does, simply ignore the return.
       */
      AsyncCallback&lt;UserOperationResult&gt; callback = new AsyncCallback&lt;UserOperationResult&gt;() {
  
          @Override
          public void onFailure( Throwable caught ) {
              // ignore
              System.out.println("logout failed:" + caught);
              caught.printStackTrace();
          }
  
          @Override
          public void onSuccess( UserOperationResult result ) {
              // ignore
              System.out.println("result=" + result);
          }
      };
  
  System.out.println("calling authentication service-&gt; logout()..." );
      this.context.getAuthenticationService().logout( MainLimsPresenter.this.context.getUser(), callback );
      // stop the ping service
      this.context.stopPingTimer();
  System.out.println( "stopped ping timer..." );
      this.context.stopBlockedTimer();
  System.out.println("stopped blocked timer..." );
  
      releaseRegistrations();
  System.out.println("released registrations..." );
  
  }
  </code></pre>
  
  <p>The generated output looks like:</p>
  
  <pre><code>mozilla/5.0 (windows nt 6.1; wow64; rv:18.0) gecko/20100101 firefox/18.0
  closing... end session
  calling main.logout()...
  in logout()...
  calling authentication service-&gt; logout()...
  stopped ping timer...
  stopped blocked timer...
  released registrations...
  back from logout()...
  </code></pre>
  
  <p>As you can see, the RPC method is being called well before the application completes, but there are no logging/debug messages from the web service service, and the user is not logged out of the underlying application.  So the RPC is really never being called.</p>
  
  <p><b>This worked fine until recent upgrade to Firefox 21</b>.  Testing shows this works for Firefox 9, 15, 16, and 17, but stopped working with version 18.0.2.  It works for Chrome (27) and IE9 as well a previous versions of Chrome and IE.</p>
  
  <p>I tried looking through the list of changes for Firefox 18 to see if there was something I could determine might affect the calling of the RPC method, but wasn't able to find anything obvious.</p>
  
  <p>Has anyone else encountered this problem or have a workaround?</p>
  
  <p>Thanks!</p>