code: public synchronized void close(CloseMode closeMode) throws IOException
      {
          Preconditions.checkState(state.compareAndSet(State.STARTED, State.CLOSED), "Already closed or has not been started");
          Preconditions.checkNotNull(closeMode, "closeMode cannot be null");
  
          cancelStartTask();
  
          try
          {
              setNode(null);
          }
          catch ( Exception e )
          {
              ThreadUtils.checkInterrupted(e);
              throw new IOException(e);
          }
          finally
          {
              client.getConnectionStateListenable().removeListener(listener);
  
              switch ( closeMode )
              {
              case NOTIFY_LEADER:
              {
                  setLeadership(false);
                  listeners.clear();
                  break;
              }
  
              default:
              {
                  listeners.clear();
                  setLeadership(false);
                  break;
              }
              }
          }
      }
docs: Remove this instance from the leadership election. If this instance is the leader, leadership
  is released. IMPORTANT: the only way to release leadership is by calling close(). All LeaderLatch
  instances must eventually be closed.
  
  @param closeMode allows the default close mode to be overridden at the time the latch is closed.
  @throws IOException errors