fix: safely close tree window with pcall and debug logging Co-authored-by: Alexander Courtis <alex@courtis.org>