I do think the scenario you describe where liquid and/or foam from an airlock is sucked into beer when cooling is a very real concern. Fortunately there are a few things that can be done to prevent this from occurring. If your beer resides in a container with a fairly narrow opening like a carboy with no pressure rating you can equip the neck of your container with a filter for the air that is pulled into the headspace as the contents of your fermenter cool.
Cotton plugs make very effective gas filters and are commonly used in laboratories to plug up the tops of test tubes and flasks used to grow all sorts of cultures. Cotton rolls can be purchased at your local pharmacy and you can make a correctly sized plug to fit the opening of your fermenter. After your fermenter has cooled you can replace the airlock because the cotton plug will allow the beer to oxidize if not replaced. If you are concerned about oxidation and are bothered by the air entering the headspace during cooling you can feed a small gas line into the neck of your fermenter before inserting the cotton plug and start a very slow flow of carbon dioxide into the headspace to create a positive flow of carbon dioxide out of the plug. This process is handy when your fermenter is not rated for pressure.
If your fermenter can tolerate a bit of pressure you have other options. A good question to ask is “how do I know if my fermenter can handle pressure?” Pressure rated vessels, like stainless steel homebrew fermenters, soda kegs, and beer kegs should be clearly labeled with the rating of the vessel. Plastic and glass containers are another story and are typically not individually labeled; this does not mean that they have no pressure rating, but determining the rating can be difficult. Plastic containers can certainly withstand some pressure, but glass containers, especially flat-bottomed carboys, can easily be broken with very little pressure. For this reason always assume glass containers have no pressure rating unless you have convincing evidence that they are pressure rated.
OK, so let’s assume your fermenter can tolerate a bit of pressure. Instead of using a cotton filter you can simply close your fermenter’s vent valve and pressurize the headspace with carbon dioxide to about 5 psi (0.3 bar) before moving your beer into a cooler environment. This headspace pressure is sufficient to seal an inward opening lid that requires internal pressure for sealing but low enough to not add significant carbonation to your beer. Since carbon dioxide is being used in this method, the gas pressure will decrease as the gas is absorbed by the beer; this means that the gas line needs to stay connected to the fermenter. If you do not want your beer to become even slightly carbonated during the cold aging step, simply disconnect the gas from the fermenter after it has cooled and equip with an airlock, and the beer will re-equilibrate with atmospheric pressure.
I have been writing this column for the past 21 years and have addressed this topic several times because it is an important consideration and is often overlooked. If a survey were conducted to determine the most relevant commonality among great beers the result would certainly be rigorous attention and understanding of cleaning and sanitation. Sometimes very clean breweries have microbiological issues. These problems can be very challenging to track down, but when they are identified and solved the root cause is frequently something that seems very basic. Preventing airlock suck back is one of those basic things that can throw a monkey wrench into an otherwise clean and tidy operation.