Stop scan thread on exit