When someone was dying at home, you always had to have a window open so that their soul could leave, even in the dead of winter.
If the window was closed, the soul would be tormented. And then somebody in the house could get sick from what they had. When their soul left, it took the sickness with them.
I’m going to go with a naturalistic explanation on this one. I think that at death, especially in Ireland, the whole family would have gathered around them. With this many people in places that typically wouldn’t have ventilation, perhaps opening a window actually did blow away bacteria in the air and keep family members breathing relatively fresh air.