Create a ThreadStoragePolicy for smart ptrs that joins the thread before it is destructed. The thread destructor cannot do it by itself (it would have destroyed half of the thread object already while the worker thread is still running), so it must be done before destroying the thread object.