Correctly stop and close recovery threads and cleanups global context.

Also decreased total number of threads and processes created and used by pytests.