title: Vaadin application: handle application closing event
body: <p>I have a portal with different available portlets. My <code>Activity</code> portlet has some background threads which must be stopped when the portlet is unloaded (for example, when selecting another portlet). The Activity portlet is of class <code>GenericPortletApplication</code>, which implements the following interfaces:</p>
  
  <pre><code>import com.vaadin.Application;
  import com.vaadin.terminal.gwt.server.PortletApplicationContext2;
  
  public abstract class GenericPortletApplication extends Application implements PortletApplicationContext2.PortletListener {
  ...
  }
  </code></pre>
  
  <p>I would like to know which method I can overload to make sure I will handle the closing of the application properly. I have tried <code>destroy</code> but this is not implemented.</p>
  
  <p>The interfaces are defined <a href="https://vaadin.com/api/com/vaadin/Application.html" rel="nofollow">here</a> and <a href="https://vaadin.com/api/com/vaadin/terminal/gwt/server/PortletApplicationContext2.html" rel="nofollow">here</a> but I can not find the method which will be called when the application is unloaded.</p>