Fix segfault at exit

Fix segfault at exit when QPython destructor is called.