code:     protected void doStop() throws Exception {
          super.doStop();
          // ensure client is closed when stopping
          if (client != null && !client.isClosed()) {
              client.close();
          }
          client = null;
      }
  
  