Ensure a query is canceled, if a thread is about to be killed.

I noticed that CTRL-C blocks Ruby, when pressed while a blocking query in the main thread. So we should ensure that the running query is stopped.

Any concerns?