Improved exit from threading execution on OSX/Linux.
Improved exit from threading execution on OSX/Linux.

madsbk/bohrium,madsbk/bohrium,bh107/bohrium,madsbk/bohrium,bh107/bohrium,bh107/bohrium,bh107/bohrium,madsbk/bohrium