Fix shutdown race between mono_thread_manage and mono_thread_detach_internal. (#5599)