Ideally instant and excess production is "saved" in a pool that stays forever until being used. The pool is immediately used up upon starting construction of a building, but the actual amount of production used is capped at max(1 turn of production, this turn's instant production).
For example, while you're working process, you gain 200

in the past turns, and 40

this turn. Your instant production pool now has 240

.
Scenario A: You switch to building a 80

building, but decide not to and switch back to process. No

is wasted.
Scenario B: You switch to building a 80

building, and the city has 20

per turn. Upon turn end, 40

is added to the building progress, and the pool is emptied.
Scenario C: You switch to building a 80

building, and the city has 60

per turn. Upon turn end, 60

is added to the building progress, and the pool is emptied. There's an excess of 40

, so it's being added to the pool again.
Scenario D: You switch to building a 80

building, and the city has 300

per turn. Upon turn end, 240

is added to the building progress, and the pool is emptied. There's an excess of 460

, so it's being added to the pool again.
You still "waste" production this way, but at least you can see what's being wasted now.