Resonant trapping: A failure mechanism in switch transitions