Stability of dynamic states in Josephson junctions