While doing a yeast starter a while back, I had a strange phenomenon happen to me that caught me off-guard. Doing a 2L starter in a glass 1/2 gallon carboy, I shake it up about every hour to ensure I am getting good aeration. While doing this, it builds up pressure as I have the cap screwed on tightly so as not to leak anything. After it settles down, I loosen the lid a bit and let it vent some of the built-up pressure (and get another dose of oxygen for the fermentation).
During this process, of course the yeast foam wants to rush out as you relieve the pressure, so you have to screw the lid back on again before you lose anything out the lid. So this day while venting through the lid, I had a slow steady stream of pressurized air going out, watching the foam raise higher in the jug. Right when it was near the lid, I screwed it down tighter only to find it suddenly rush out and foam out of the carboy.
After this happened a couple of times, I figured out what was going on with the physics of it. By letting it establish a steady flow rate, when I started tightening the lid I was decreasing the area it had to flow through, which made the flow speed up. Same phenomenon as a garden hose when you start to bend it over to pinch the flow.
So next time around, I’ll either not let the foam get too close to the lid before tightening the lid down, or not let it build up a steady flow stream by venting for a period of time.