On the thermodynamics of materials with memory