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 onCloseShouldCallForceOnTheCncByteBuffer(@TempDir final Path dir)
    {
        final MappedByteBuffer cncByteBuffer = spy(IoUtil.mapNewFile(dir.resolve("test.cnc").toFile(), 1024));
        final DriverConductor conductor = new DriverConductor(ctx.clone().cncByteBuffer(cncByteBuffer));

        conductor.onClose();

        final InOrder inOrder = inOrder(toDriverCommands, cncByteBuffer);
        inOrder.verify(toDriverCommands).consumerHeartbeatTime(Aeron.NULL_VALUE);
        inOrder.verify(cncByteBuffer).force();
    }