Terminate clients after queries