fixed small error in windowClosing handler
added more debug logging statements