closeEvent improvement