If you try to close or set to autohide a ToolWindow in ActiveWindowChanged event and the ActiveWindowChanged is fired because you are trying to dock another ToolWindow (currently set to autohide), you may activate the wrong ToolWindow at the end.