Now using thread_launcher function to properly clean up thread resources at exit.