Added at_exit hook to shutdown the global thread pool.