As the door nears the door frame there reaches a point where the door, for a moment, effectively seals off the air in the room from the air outside the room. This only happens for a moment, since most doors aren't 100% air proof. When this happens, as the door continues to close it decompresses the air inside the room, because the volume of the room increases as the door continues to close but the amount of air inside the room doesn't change because the room is briefly sealed off from outside the room. Thus there is an air pressure difference across the door, with the greater pressure coming from outside the room. This greater pressure slows the door down right before it closes.
On the other hand, with a window open air is let into the room and so even though the volume of the room increases as the door closes the air pressure from outside the window pushes air into the room to keep the air pressure inside the room about the same as outside. No pressure air pressure difference is found across the door and thus it does not slow down.
It is also possible that a fan or something inside the building could be creating a lower air pressure inside the building and thus there is a small air flow from the window into the building, which would push the door to close faster one the above-described brief sealing of the room happens, thus increasing the volume of the "slam!".
Puerta is "door" in Spanish; "window" is ventana. "Open the door & close the window" is Abra la puerta y cierre la ventana.
A house is typically a structure that has both doors and windows. !