Linux thread and util fixes.

C.pthread_exit() will chash in linux and is undestandable. Its is
better to let lua state to close down by itself.