Fixed thread init/teardown bug which caused segfault on badarg.

Fixed mem leaks in args handling on badarg condition.