fix module destruction during context switch