Scaling of entanglement close to a quantum phase transition