Fix tree auto-close behavior