Allow query caught in endless recursion to be killed

When writing a recursive function, it is relatively easy to create an endless loop. Due to tail optimization such a query may not generate a stack overflow, but continues to run forever. Make function calls check the xquery watchdog to allow users to kill a looping query.