finalize threads.