Multiple times that I’ve gone to San Francisco Giants games, the seagulls sensed when the game was ending so they could pick up food. https://youtu.be/LPra_ZfwanU
Many animals, particularly some birds, are smarter than we give them credit for. Corvids, for example, are known to not only use tools, but are capable of planning and understanding some cause-and-effect scenarios that require patience.
I know practically nothing about baseball, but if it's like any other human gathering, there are probably a lot of clues that the birds learn:
- Noise levels. Big events often culminate in some big fanfare with noise (cheering, music, etc.). If the game changes audibly near the end, you can bet the birds have noticed.
- Motion/activity: Any large gathering I've ever gone to often has a small percentage of people leaving early because they want to avoid the crowd or traffic. I'd expect a close-scored game has fewer people leaving, but chances are good that as enough people start getting up to leave, it's another signal the birds can use.
- Discarded food: Aside from getting up to leave, toward the end of an event many people will start discarding snacks and drinks. Hopefully in the correct bin, but often just on the ground (humans are messy -- which seagulls love). An increased number of people tossing garbage into bins (and missing or they start overflowing) signals a few gulls that there's scraps to be found.
- Temporal. If these events happen regularly, or even irregularly, the birds associate it with food. People filling a stadium or parking lot, playing music, buying food (birds do have a sense of smell, though not as developed as mammals), etc. The birds over time learn: Increased human activity at this location results in more food some hours later.
Gulls are very gregarious, and notice when just one bird has found a morsel. As soon as a few birds get the first discards, the rest of the flock notices and starts to mobilize; circling and calling.
I would argue that the birds don't really know when a game or event is about to end, but they are adept at reading their environment, even if it's an urban one.
Per @theforestecologist's comment, references are requested. While I do not have a reference for each specific behavior described above, the following list covers avian intelligence generally, learning and problem-solving, and physiological adaptations. Many of the described behaviors are products of associative learning and elaborate communication, traits that gulls exhibit in other activities such as dropping clams from heights.
Ravens parallel great apes in flexible planning for tool-use and bartering
Can Kabadayi, Mathias Osvath
Science; 14 July 2017, Vol. 357, Issue 6347
Ecology and Conservation of Birds in Urban Environments
edited by Enrique Murgui, Marcus Hedblom
Springer Nature; 10 February 2017
Cognitive ornithology: the evolution of avian intelligence
Nathan J. Emery
Philosophical Transactions of the Royal Society of London; 7 Dec 2005, Vol. 361
Bloomsbury Publishing; 2 Feb 2012
Auditory and visual mechanisms in food-finding behavior of the Herring Gull
Hubert Frings, Mable Frings, Beverly Cox, and Lorraine Peissner
Wilson Bulletin 67; January 1955