Implemented fixes for instability introduced as a result of fixing the
closeEvent handling in order to clean up resources.