Fix for threads not being terminated when loading or saving