"The Masque of the Red Death" by Edgar Allan Poe is based loosely on accounts of the Black Death, a plague caused by yersinia pestis that may have killed as many as 100 million people in the fourteenth century. To escape the Black Death, many nobles left the cities and retreated to their country estates. One important literary work that may have influenced Poe's account is Boccaccio's The Decameron, which describes a party of ten nobles entertaining each other with tales in a secluded villa outside Florence to which they had retreated to escape the Black Death.
In Poe's story, Prospero and his guests have isolated themselves in a castle, which no one can enter and from which no one can leave. Although they think their isolation will keep them safe, the Red Death appears at a masquerade and infects everyone in the castle. Far from the walls keeping out the Red Death, they trap the guest inside with it.