Dynamic stability of elastically constrained beams: an exact approach