Fixed thread not stopping issue.