Finish query implementation.