Correctly terminate when interrupted.

When handling the InterruptedException, reset the interrupted flag.

Moreover, when the thread is about to quit, do not start another query,
as this might no longer be valid. This was causing the test to be flaky.

Change-Id: I5654147a10659639efcbfda0d7e52df489b76ecd
1 file changed