Stabilization of the internal kink mode in finite beta toroidal plasmas