Fix bug of search thread cannot stop correctly.