The reason for this is that when you close a window, mIRC has to designate an active window internally. This remains the active window until mIRC receives a window activation message from Windows. This message may never come (for example, when you close the desktop @window, this may switch you to another application). Once mIRC does receive a window activation message, it sets that window as the active window. So no matter how this is implemented, you will always see a temporary change in focus in the treebar/switchbar. However, I can probably improve this a little more by checking window ordering and setting the next active window that way. This will be in the next beta.