fix BufferError: cannot close exported pointers exist
for some reason, even though the ctypes object falls out of function
scope, it causes a lingering reference.
in any case, the use of ctypes is no longer necessary.
Don't change temporary files mid-way for Darwin
This fixes the CI issues on Darwin.
close the remote process on app shutdown.