In a Stark decelerator, polar molecules are slowed down and focussed by an inhomogeneous electric field which switches between two configurations. For the decelerator to work, it is essential that the molecules follow the changing electric field adiabatically. When the decelerator switches from one configuration to the other, the electric field changes in magnitude and direction, and this can cause molecules to change state. In places where the field is weak, the rotation of the electric field vector during the switch may be too rapid for the molecules to maintain their orientation relative to the field. Molecules that are at these places when the field switches may be lost from the decelerator as they are transferred into states that are not focussed. We calculate the probability of nonadiabatic transitions as a function of position in the periodic decelerator structure and find that for the decelerated group of molecules the loss is typically small, while for the un-decelerated group of molecules the loss can be very high. This loss can be eliminated using a bias field to ensure that the electric field magnitude is always large enough. We demonstrate our findings by comparing the results of experiments and simulations for the Stark deceleration of LiH and CaF molecules. We present a simple method for calculating the transition probabilities which can easily be applied to other molecules of interest.