Switching control of resistive switching devices