use a thread to kill query periodically