Fixes ofThread destructor behavior. uses tryJoin with a timeout of 10 seconds to wait for thread to finish. closes #1239

This does what @damiannz requested in #1239 
Tested with an example where the threaded function is sleeping for a long period of time. 
The example correctly waits for the thread to end before exiting the app.