This method is called from ApplicationContext.ExitThread.
ApplicationContext.ExitThread and ApplicationContext.ExitThreadCore do not actually cause the thread to terminate. These methods raise the Application.ThreadExit event to which the System.Windows.Forms.Application object listens. The System.Windows.Forms.Application object then terminates the thread.