Geophysical and astrophysical flows are often anisotropic, leading to energy cascades towards both larger and smaller scales and a forward-to-inverse flux ratio that depends on the degree of anisotropy, controlled by the relevant geophysical control parameter (rotation rate, stratification, aspect ratio, etc.). Starting from a purely forward cascade, as the anisotropy is continuously increased, the emergence of an inverse cascade is observed to appear at a critical value of the control parameter. In this talk, we show that the sharp transition from a forward to an inverse cascade also occurs in a shell model for two-dimensional magnetohydrodynamics, and analyze its behavior at the transition point. We pay particular attention to the statistical behavior of the complex phases, whose nonlinear coupling and synchronization are ultimately responsible for energy transfers. Our investigation of the complex phases reveal a sudden change in synchronization at the scale where magnetic energy is similar to the kinetic energy. When this scale reaches the forcing scale, it results in no net transfer of energy to large scales and shuts off the inverse cascade.