fix crashes when deallocating instances of cimported types after module cleanup, patch by Lisandro Dalcin