Fix race condition between a domain unload and a runtime shutdown.
When a regular runtime shutdown and a domain unload starts mostly in parallel
it might happen that the unload initiator will deadlock waiting on the unload thread
for two reasons:
The unload thread will block when attaching as the runtime believe it's better
to not finish it as it's going down. To fix this we now use mono_thread_attach_full
and force it to be attached.
The unload initiator might deadlock on the wait loop if the shutdown initiator aborts
it instead of the unload thread. This happens if the unload was done from outside of
the domain been teared down.
The fix here is to add a variable that the initiation test on every loop, which is the
right thing to do when using wait loops on handles. This might degrade into a busy
loop when the above race condition happens. It's rare enough that it's not worth
fixing it now.