public void close(final Runnable onInitialClose) {
        close(onInitialClose, null);
    }
Closes the resource in a thread-safe manner.

<p/>

After the execution has completed, calls to {@link #isClosed()} will return {@code false} and calls to
{@link #assertOpen(String)} and {@link #assertOpen(Supplier)}
will throw an {@link IllegalStateException}.

@param onInitialClose Optional {@link Runnable} to execute when the resource is closed. Note that the
                      object will still be considered closed even if an exception is thrown during the course
                      of its execution; can be {@code null}
clients/src/main/java/org/apache/kafka/common/internals/IdempotentCloser.java