code: public void close() {
          xlogger.entry();
          logger.debug("closing all event resources");
  
          if (heartBeatExecutor != null) {
              heartBeatExecutor.shutdown();
              try {
                  heartBeatExecutor.awaitTermination(1, TimeUnit.SECONDS);
              } catch (final InterruptedException e) {
                  logger.error("could not stop event hearbeat");
                  Thread.currentThread().interrupt();
              }
          }
  
          if (context != null) {
              // close all open sockets
              context.destroy();
          }
          eventImplMap.clear();
  
          isInitialized = false;
          logger.debug("all event resources closed");
          xlogger.exit();
      }
docs: Close all zmq resources