code: private void leave(CompletableFuture<Void> future) {
      // Set a timer to retry the attempt to leave the cluster.
      leaveTimeout = context.getThreadContext().schedule(context.getElectionTimeout(), () -> {
        leave(future);
      });
  
      // Attempt to leave the cluster by submitting a LeaveRequest directly to the server state.
      // Non-leader states should forward the request to the leader if there is one. Leader states
      // will log, replicate, and commit the reconfiguration.
      context.getServerState().leave(LeaveRequest.builder()
        .withMember(member())
        .build()).whenComplete((response, error) -> {
        // Cancel the leave timer.
        cancelLeaveTimer();
  
        if (error == null && response.status() == Response.Status.OK) {
          Configuration configuration = new Configuration(response.index(), response.term(), response.timestamp(), response.members());
  
          // Configure the cluster and commit the configuration as we know the successful response
          // indicates commitment.
          configure(configuration).commit();
          future.complete(null);
        } else {
          // Reset the leave timer.
          leaveTimeout = context.getThreadContext().schedule(context.getElectionTimeout(), () -> {
            leave(future);
          });
        }
      });
    }
docs: Attempts to leave the cluster.