Cannabis plants are annual flowering plants, meaning as they "sense" (or perceived sense) fall is approaching, they fruit and flower as an attempt to reproduce before its too late and they die. That is what it means to be an annual, they are preparing for death, but their hoping to get pollinated so the seeds can drop to the ground and sprout up next spring. So as fall approaches it begins to shed its leaves and scrounge up all that extra energy stored in the fan leaves to aid the budding process. It is as natural as the trees changing to "fall colors" as they shed their leaves and get ready for the winter. Nitrogen concentrations in the leaf tissue go down as the plant realizes "Oh there isn't as much sun so I don't need to produce as many green leaves to grow big and tall", so the plants turn yellow and sometimes purple approaching harvest. I usually aim to have my plants eat up most of their fan leaves by the time the fruit is ready. I have found that if nitrogen concentrations are too high at harvest, the buds can attain more of a "grassy" flavor that requires a good long cure to get out.
The way the plants get energy in the first place is by breaking down the stored nutrients that are mainly stored in the cellulose or, woody fibers of the plant, it is polymers of sugar where it can "harvest" its own sugars internally to supply itself with energy. The nutrients you give it don't
directly supply it energy, rather it gives the plant the compounds it needs to metabolize the stored energy efficiently throughout the plant. I normally aim to have all my leaves yellow in "synchronis" or in a balanced manner, but however usually the oldest leaves on the bottom which receive less light underneath the canopy will die off first. So yellow leaves in late flower are nothing new.