  The loss of magnetic pressure accompanying the decay of the magnetic field in
a magnetar may trigger exothermic electron captures by nuclei in the shallow
layers of the stellar crust. Very accurate analytical formulas are obtained for
the threshold density and pressure, as well as for the maximum amount of heat
that can be possibly released, taking into account the Landau-Rabi quantization
of electron motion. These formulas are valid for arbitrary magnetic field
strengths, from the weakly quantizing regime to the most extreme situation in
which electrons are all confined to the lowest level. Numerical results are
also presented based on experimental nuclear data supplemented with predictions
from the Brussels-Montreal model HFB-24. This same nuclear model has been
already employed to calculate the equation of state in all regions of
magnetars.
