private static bool OnConsoleCtrlMessage(CtrlTypes ctrlType)
        {
            ChoFramework.Shutdown();

            String message = "This message should never be seen!";

            // A switch to handle the event type.
            switch (ctrlType)
            {
            case CtrlTypes.CTRL_C_EVENT:
                message = "A CTRL_C_EVENT was raised by the user.";
                break;

            case CtrlTypes.CTRL_BREAK_EVENT:
                message = "A CTRL_BREAK_EVENT was raised by the user.";
                break;

            case CtrlTypes.CTRL_CLOSE_EVENT:
                message = "A CTRL_CLOSE_EVENT was raised by the user.";
                break;

            case CtrlTypes.CTRL_LOGOFF_EVENT:
                message = "A CTRL_LOGOFF_EVENT was raised by the user.";
                break;

            case CtrlTypes.CTRL_SHUTDOWN_EVENT:
                message = "A CTRL_SHUTDOWN_EVENT was raised by the user.";
                break;
            }

            throw new ChoConsoleCtrlException(message);
        }
        /// <summary>
        /// If we are presently showing a mainForm, clean it up.
        /// </summary>
        protected override void ExitThreadCore()
        {
            ChoFramework.Shutdown();

            if (_mainFormWindow != null)
            {
                // before we exit, give the main form a chance to clean itself up.
                _mainFormWindow.Close();
            }
            else
            {
                Environment.Exit(0);
            }
            base.ExitThreadCore();
        }
        /// <summary>
        /// If we are presently showing a mainForm, clean it up.
        /// </summary>
        protected override void ExitThreadCore()
        {
            ChoWindowsManager.ShowConsoleWindow();

            ChoFramework.Shutdown();

            if (_mainFormWindow != null)
            {
                // before we exit, give the main form a chance to clean itself up.
                _mainFormWindow.Close();
            }
            else
            {
                Environment.Exit(0);
            }

            if (System.Windows.Application.Current != null)
            {
                System.Windows.Application.Current.Shutdown();
            }

            base.ExitThreadCore();
        }