public void AddInDomainFinalized()
        {
            long val = Interlocked.Decrement(ref _addInAppDomains);

            if (!_startedExitProcess && val == 0)
            {
                try
                {
                    // the host will call ExitProcess here if it is not cancelled
                    _eventWorker.SendShutdownMessage();
                }
                catch (RemotingException)
                {
                    // the application likely has shut down itself.
                    // The main thread will shut down this app
                }
            }
        }