Unifying finite-temperature dynamical and excited-state quantum phase transitions