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

This fixes blocked Ruby when pressing CTRL-C for a blocking query in
the main thread.
Use async_exec for compat with Ruby-1.8
Merge pull request #9 from larskanis/cancel-query-ubf

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