Even the best canine swimmer sometimes ends up slipping its head below water and I was wondering if they know to exhale or close off their nose to prevent the water from entering their nose?
As far as I know dogs cannot physically close their nostrils, among mammals only the aquatic ones possess such mechanisms.
But completely sealed nostrils are not actually that necessary because water entering just the nose itself is not that dangerous - it's the deeper parts of the respiratory system that must be protected - and such protection mechanisms preventing the water from entering the bronchi and the lungs exist.
An involuntary response called diving reflex exists in mammals and, among other things, causes cessation of breathing in response to wetting nostrils and face regions with cold water - and the colder the water is, the more pronounced is the response. And even if some water passes through or is somehow aspired, immediate coughing would be provoked, expelling the water from respiratory system.