Fix MAGN1423. Cleanup FFI when resetting the VM