public void UserLeaveLot() { if (Thread.Context.VM.EODHost != null) { Thread.Context.VM.EODHost.ForceDisconnect(this); //try this a lot. } if (Thread.Queue.Exists(x => x.ActionRoutine.ID == LEAVE_LOT_TREE && Thread.Queue.IndexOf(x) <= Thread.ActiveQueueBlock + 1)) { return; //we're already leaving } var actions = new List <VMQueuedAction>(Thread.Queue); foreach (var action in actions) { Thread.CancelAction(action.UID); } var tree = GetBHAVWithOwner(LEAVE_LOT_TREE, Thread.Context); var routine = Thread.Context.VM.Assemble(tree.bhav); Thread.EnqueueAction( new FSO.SimAntics.Engine.VMQueuedAction { Callee = this, CodeOwner = tree.owner, ActionRoutine = routine, Name = "Leave Lot", StackObject = this, Args = new short[4], InteractionNumber = -1, Priority = short.MaxValue, Flags = TTABFlags.Leapfrog | TTABFlags.MustRun } ); if (KillTimeout == -1) { KillTimeout = 0; } }