call detach method on thread exit
Merge pull request #8577 from ntotani/detach-thread-on-exit

call detach method on thread exit