Terminate thread on stop.