@Test
    public void shouldFinishGlobalStoreOperationOnShutDown() throws Exception {
        kafkaStreams = new KafkaStreams(builder.build(), streamsConfiguration);
        populateTopics(globalStoreTopic);
        populateTopics(streamTopic);

        kafkaStreams.start();

        TestUtils.waitForCondition(
            () -> firstRecordProcessed,
            30000,
            "Has not processed record within 30 seconds");

        kafkaStreams.close(Duration.ofSeconds(30));

        final List<Long> expectedRetrievedValues = Arrays.asList(1L, 2L, 3L, 4L);
        assertEquals(expectedRetrievedValues, retrievedValuesList);
        assertEquals(1, closeCounter.get());
    }
This test asserts that when Kafka Streams is closing and shuts
down a StreamThread the closing of the GlobalStreamThread happens
after all the StreamThreads are completely stopped.

The test validates the Processor still has access to the GlobalStateStore while closing.
Otherwise if the GlobalStreamThread were to close underneath the StreamThread
an exception would be thrown as the GlobalStreamThread closes all global stores on closing.
streams/src/test/java/org/apache/kafka/streams/integration/GlobalThreadShutDownOrderTest.java