  Achromatic breaks in afterglow light curves of gamma-ray bursts (GRBs) arise
naturally if the product of the jet's Lorentz factor \gamma and opening angle
\Theta_j satisfies (\gamma \Theta_j) >> 1 at the onset of the afterglow phase,
i.e., soon after the conclusion of the prompt emission. Magnetohydrodynamic
(MHD) simulations of collimated GRB jets generally give (\gamma \Theta_j) <~ 1,
suggesting that MHD models may be inconsistent with jet breaks. We work within
the collapsar paradigm and use axisymmetric relativistic MHD simulations to
explore the effect of a finite stellar envelope on the structure of the jet.
Our idealized models treat the jet-envelope interface as a collimating rigid
wall, which opens up outside the star to mimic loss of collimation. We find
that the onset of deconfinement causes a burst of acceleration accompanied by a
slight increase in the opening angle. In our fiducial model with a stellar
radius equal to 10^4.5 times that of the central compact object, the jet
achieves an asymptotic Lorentz factor \gamma ~ 500 far outside the star and an
asymptotic opening angle \Theta_j ~ 0.04 rad ~ 2 deg, giving (\gamma \Theta_j)
~ 20. These values are consistent with observations of typical long-duration
GRBs, and explain the occurrence of jet breaks. We provide approximate analytic
solutions that describe the numerical results well.
