Quantum thermodynamics at impurity quantum phase transitions