Added debug messages and corrected the closeEvent handler call for future program cleanup implementation.