void cleanup() {
        log.trace("Closing the consumer network thread");
        Timer timer = time.timer(closeTimeout);
        try {
            runAtClose(requestManagers.entries(), networkClientDelegate);
        } catch (Exception e) {
            log.error("Unexpected error during shutdown. Proceed with closing.", e);
        } finally {
            sendUnsentRequests(timer);
            applicationEventReaper.reap(applicationEventQueue);

            closeQuietly(requestManagers, "request managers");
            closeQuietly(networkClientDelegate, "network client delegate");
            log.debug("Closed the consumer network thread");
        }
    }
Check the unsent queue one last time and poll until all requests are sent or the timer runs out.
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerNetworkThread.java