public void OnClose()
        {
            if (isServiceActive)
            {
                isServiceActive = false;
                try
                {
                    service.OnTerminate(this);
                }
                catch (Exception ex)
                {
                    ctx.CountedErrorHandler().OnError(ex);
                }
            }

            if (!ctx.OwnsAeronClient())
            {
                foreach (ClientSession session in sessionByIdMap.Values)
                {
                    session.Disconnect();
                }

                logAdapter?.Dispose();
                _consensusModuleProxy?.Dispose();
                _serviceAdapter?.Dispose();
            }

            ctx.Dispose();
        }
        public void OnClose()
        {
            if (!ctx.OwnsAeronClient())
            {
                logAdapter?.Dispose();
                _consensusModuleProxy?.Dispose();
                _serviceAdapter?.Dispose();

                foreach (ClientSession session in sessionByIdMap.Values)
                {
                    session.Disconnect();
                }
            }
        }