This happens automatically in the normal modal case (i.e. when XTF_MODELESS not set). Otherwise, you must explicitly destroy the tree control using XTR_OPCODE 3, or, since it is just another control object (like buttons, static text, etc.) it may be destroyed using Tab (-1,0). If the XTREE control is within another control (such as a dialog or Tab), then you may also destroy it by using AUI_CONTROL or Tab (-10,20) with opcode 4 and specifying the control ID of the parent.