Fix the query extension to handle blocks that end in nil.

I hadn't actually run the new query block implementation against my test suite until now, but I commonly use conditionals in query blocks, and things blow up if the block ends in nil. The fix is small and simple.

Thanks!