It's supposed to steal the focus only when closing the context menu.
Even if the focus was not on the treeview, I think it should give the focus to the treeview anyway.
At this point, I'll let you choose what the right thing to do is.