Add dbg_exit() function, finish thread_mutex runtime checks