Fix deadlock in ot_terminate()

The method acquires a lock on the static mutex `the_Mutex`.

It then calls itself recursively by re-throwing the exception and hangs because
it has already acquired the lock.

This freezes the process on my Linux system, but it should freeze on other
systems as well.

It's unclear what the purpose of the lock is, I'm guessing guarding the std::err
output. I moved it further down where it is less likely that a recursion
occurs. A better way would be to get rid of the mutex in this method altogether.