The door opens and closes when you press "B", introduced in the 1.3 update. The door is crafted using 10 wood and 1 iron. When open, they allow light flow through the door, and not to mention the undead. When closed, the amount of light that passes through the door is cut off and it prevents the undead from entering the building (except for Dragons, they'll just destroy the building) so make sure your house is made out of strong materials such as Iron, Gold, Diamond, and Bloodstone in order to avoid getting yourself killed while indoors. If placed like windows they can be used to make gunholes that you can open and fire out then close if need be E.G if a skeleton appears.