Let threads stop properly.