Use return instead of goto for thread exits