code: protected void teardown() throws Exception {
      logger.fine("shutting down channels");
      for (ManagedChannel channel : channels) {
        channel.shutdown();
      }
      logger.fine("shutting down server");
      server.shutdown();
      if (!server.awaitTermination(5, TimeUnit.SECONDS)) {
        logger.warning("Failed to shutdown server");
      }
      logger.fine("server shut down");
      for (ManagedChannel channel : channels) {
        if (!channel.awaitTermination(1, TimeUnit.SECONDS)) {
          logger.warning("Failed to shutdown client");
        }
      }
      logger.fine("channels shut down");
    }
docs: Shutdown all the client channels and then shutdown the server.