Dynamical instability and switching of resonant tunneling device under terahertz radiation