How do flame tests give off color if they only emit the colors when the electrons return to ground state?

Since we are constantly holding the element in the fire and the elements only give off the color when the electrons emit the energy that was supplied and return to ground state, why do we only see the colors when in the fire and don't see the colors when we take the supplied energy ( i.e., the fire) away?

• Because in you sample there are enough atoms able to absorb energy and release it as light. It's the relaxation to ground that emits not the ground itself. "The colour is the energy not the ground" – Alchimista Jan 7 at 8:54

The flame area is a violent place due to high temperature favoring ionization. The color appears due to the dynamic process of the formation of short-lived species formed briefly in the flame. As we are burning hydrocarbons, they get split into unstable radicals easily loosing unpaired electrons. In the area of the flame enriched with electrons metal ions from the probe such as $$\ce{Na+}$$ are reduced to the metal atoms:

$$\ce{Na+ + e- -> Na^0}$$

which are emitting yellow light in a form of observable doublet of spectral lines ($$λ_1 = \pu{589.0 nm}$$, $$λ_2 = \pu{589.5 nm}$$) arising from the electronic transitions $$\ce{3s^1 -> 3p^1}$$. Note that it is the metal atom, not the ion, that is responsible for the emission of light of the given color.

So, as long as we keep the test probe (metal salt) in the flame, we can observe spectral lines of the given element as both conditions are fulfilled (energy supply (heat) and reducing atmosphere (free electrons from the fuel)). By taking the sample out of the flame, electron transitions are no longer possible as there is neither metal atoms capable of any, nor enough energy to promote the electron to the higher level.

• $3s^1$ to $3p^1$ emission? I thought the energy release was the other way around. – Oscar Lanzi Jan 7 at 15:55
• Is reducing atmosphere really a requirement? – aventurin Jan 7 at 16:04
• @OscarLanzi Yes, you are right, maybe I badly formulated it. I meant that $\ce{3s^1 -> 3p^1}$ transition precedes the energy release which occurs due to $\ce{3p^1 -> 3s^1}$. – andselisk Jan 7 at 16:12
• @aventurin Not always, I just took sodium salt with sodium ion without any electrons on the outer shell to transfer in the first place, so one needs to reduce it first in order to observe any light emission. – andselisk Jan 7 at 16:15

Electrons are pushed into excited states and fall back to the ground state all the time while their atoms are in the flame. They don't wait in the excited state until they're out of the flame.