/** Stops the filter and the attached routes. */
  @Override
  public synchronized void stop() throws Exception {
    if (isStarted()) {
      if (getDefaultRoute() != null) {
        getDefaultRoute().stop();
      }

      for (Route route : getRoutes()) {
        route.stop();
      }

      super.stop();
    }
  }
 /** Attempts to {@link #stop()} the Restlet if it is still started. */
 @Override
 protected void finalize() throws Throwable {
   if (isStarted()) {
     stop();
   }
 }