Quantum impurity in a nearly critical two-dimensional antiferromagnet