public async Task <DisconnectResponse> Handle(DisconnectArguments request, CancellationToken cancellationToken)
        {
            _debugEventHandlerService.UnregisterEventHandlers();
            if (_debugStateService.ExecutionCompleted == false)
            {
                _debugStateService.ExecutionCompleted = true;
                _powerShellContextService.AbortExecution(shouldAbortDebugSession: true);

                if (_debugStateService.IsInteractiveDebugSession && _debugStateService.IsAttachSession)
                {
                    // Pop the sessions
                    if (_powerShellContextService.CurrentRunspace.Context == RunspaceContext.EnteredProcess)
                    {
                        try
                        {
                            await _powerShellContextService.ExecuteScriptStringAsync("Exit-PSHostProcess").ConfigureAwait(false);

                            if (_debugStateService.IsRemoteAttach &&
                                _powerShellContextService.CurrentRunspace.Location == RunspaceLocation.Remote)
                            {
                                await _powerShellContextService.ExecuteScriptStringAsync("Exit-PSSession").ConfigureAwait(false);
                            }
                        }
                        catch (Exception e)
                        {
                            _logger.LogException("Caught exception while popping attached process after debugging", e);
                        }
                    }
                }

                _debugService.IsClientAttached = false;
            }

            _logger.LogInformation("Debug adapter is shutting down...");

#pragma warning disable CS4014
            // Trigger the clean up of the debugger. No need to wait for it.
            Task.Run(_psesDebugServer.OnSessionEnded);
#pragma warning restore CS4014

            return(new DisconnectResponse());
        }