Moisture continues to escape after the item is removed from the oven. At the same time, cooling begins, which causes the gases still inside the item to contract. If the protein structure is completely set, the product may shrink slightly but hold its shape. If the product is underbaked, however, the contraction of gases may cause it to collapse.
When baked goods are removed from the oven, the surface is drier than the interior crumb. During cooling, the moisture content tries to equalize throughout the item. As a result, crisp crusts gradually become softer.