@Override
    public void terminate() throws Exception {
        isRunning = false;
        // wait for all containers to stop
        trackerOfReleasedResources.register();
        trackerOfReleasedResources.arriveAndAwaitAdvance();

        // shut down all components
        Exception exception = null;

        if (resourceManagerClient != null) {
            try {
                resourceManagerClient.stop();
            } catch (Exception e) {
                exception = e;
            }
        }

        if (nodeManagerClient != null) {
            try {
                nodeManagerClient.stop();
            } catch (Exception e) {
                exception = ExceptionUtils.firstOrSuppressed(e, exception);
            }
        }

        if (exception != null) {
            throw exception;
        }
    }
@Test
    void testTerminationDoesNotBlock() throws Exception {
        new Context() {
            {
                runTest(
                        () -> {
                            try {
                                runInMainThread(() -> getDriver().terminate());
                            } catch (Exception ex) {
                                log.error("cannot terminate driver", ex);
                                fail("termination of driver failed");
                            }
                        });
            }
        };
    }