The mechanism is complicated by quantum chemistry aspects, but the principle can be tracked down to the low level classical electrostatic energy analysis, or even to the classical gravitational orbit energy analysis.
An object $O$ is on a circular orbit around a massive central object $C$. This $C$ puts the attractive force $F=A/r^2$ on the object $O$ (this is common for gravity and electrostatic force) .
The $O$ has:
- potential energy $E_\mathrm{p}=-\frac Ar$
- kinetic energy $E_\mathrm{k}=\frac A{2r}$
- total energy $E=E_\mathrm{p} +E_\mathrm{p}=-\frac {A}{2r}$
If the object is orbiting along an elliptical orbit, the values of kinetic and potential energies are just the mean values, with the total energy as their sum being constant.
The potential energy is equal to the mechanical work to be done to free the object from the force field of the central force.
The quantum chemistry complicates it a lot, but with great simplification the following is valid:
Exothermic reactions releasing energy get the energy from energy of valence electrons. These electrons form during the reaction "lower orbits" ( molecular orbitals) with less energy. This less energy means more energy would be needed to release them as free electrons.
The above mentioned molecular orbital has 3 main meanings:
It is a wave function as a particular solution of electron wave equation
Determines probability of electron occurrence in particular location
Determines quantum state of the electroncluding, but not limited to, its energy.
The quantum aspects put specific limitations, mainly these:
Only particular values of electron energy and of some other quantities are allowed
Electrons do not have classical orbits, nor particular position nor velocity.