Workaround for QImaging exit bug
Force garbage collector to run only in the main GUI thread (to avoid
crashes caused by collecting Qt objects from non-GUI threads)
Fixed lockup caused by use of QApplication.processEvents()