Detach c thread of Java thread before exit. Fix for error "thread exiting, not yet detached (count=0)"