According to the best website on the topic, "when the peristaltic contraction reaches the pylorus, its lumen is effectively obliterated - chyme is thus delivered to the small intestine in spurts....Liquids readily pass through the pylorus in spurts, but solids must be reduced to a diameter of less than 1-2 mm before passing the pyloric gatekeeper. Larger solids are propelled by peristalsis toward the pylorus, but then refluxed backwards when they fail to pass through the pylorus - this continues until they are reduced in size sufficiently to flow through the pylorus."
If you eat after a meal (i.e. snacking), before the stomach has emptied, what happens? Any liquids or very small bits would almost immediately begin passing the pylorus, but large chunks would swirl in the grinder until they're small enough. But can the stomach segregate new snack bits from older meal bits? Or does adding snacks on top of still-digesting meals slow exit of all food while the stomach continues grinding? Interestingly, I found out that one of the functions of the stomach is to coagulate colloids (e.g. milk) with acid and protease so that they don't immediately enter the small intestine.
Has does the stomach know when to empty? What controls it? The small intestine can exert negative feedback control on the stomach, slowing down peristalsic emptying if the small intestine is full. In other words, the stomach is a holding tank until the small intestine is ready, and it slows down or speeds up peristalsis to small intestine.
I think even the feeling of intense hunger, which feels like it emanates from the lower stomach, is not the stomach at all but the small intestine communicating, "I'm ready for more!". It is the body speaking to the mind....that raw pang of yearning and focus is the voice of the body.
This website is a great resource!