Finish query command implementation