public void onClose()
    {
        if (asyncTaskExecutor instanceof ExecutorService)
        {
            try
            {
                final ExecutorService executor = (ExecutorService)asyncTaskExecutor;
                executor.shutdownNow();
                if (!executor.awaitTermination(EXECUTOR_SHUTDOWN_TIMEOUT_SECONDS, TimeUnit.SECONDS))
                {
                    ctx.errorHandler().onError(new AeronEvent("failed to shutdown async task executor"));
                }
            }
            catch (final Exception e)
            {
                ctx.errorHandler().onError(e);
            }
        }
        CloseHelper.close(ctx.errorHandler(), nameResolver);
        publicationImages.forEach(PublicationImage::free);
        networkPublications.forEach(NetworkPublication::free);
        ipcPublications.forEach(IpcPublication::free);
        freeEndOfLifeResources(Integer.MAX_VALUE);
        toDriverCommands.consumerHeartbeatTime(Aeron.NULL_VALUE);
        ctx.cncByteBuffer().force();
        ctx.close();
    }
@Test
    void onCloseShouldNotifyIfExecutorDoesNotCloseOnTime(@TempDir final Path dir) throws InterruptedException
    {
        final ExecutorService asyncTaskExecutor = mock(ExecutorService.class);
        final DriverConductor conductor = new DriverConductor(ctx.clone()
            .cncByteBuffer(IoUtil.mapNewFile(dir.resolve("some.txt").toFile(), 64))
            .asyncTaskExecutor(asyncTaskExecutor));

        conductor.onClose();

        final InOrder inOrder = inOrder(asyncTaskExecutor, mockErrorHandler);
        inOrder.verify(asyncTaskExecutor).shutdownNow();
        inOrder.verify(asyncTaskExecutor).awaitTermination(EXECUTOR_SHUTDOWN_TIMEOUT_SECONDS, SECONDS);
        inOrder.verify(mockErrorHandler).onError(argThat(
            arg -> arg instanceof AeronEvent &&
            arg.getMessage().equals("WARN - failed to shutdown async task executor")));
        inOrder.verifyNoMoreInteractions();
    }