Fixed some issues for gthread_exit