Thermodynamic conditions for stability in materials with rate-independent dissipation