Sudip Bose at The American Scholar:
In the spring of 1815, already beset by poor health, Percy Shelley was tormented by a spell of coughing so vicious, and a pain in his side so intense, that he became convinced he was about to die. “An eminent physician,” wrote Mary Godwin (soon to be Mary Shelley), diagnosed the malady as consumption, and so, throughout the spring and well into the summer, the poet was obsessed with thoughts of his mortality. He began imagining what might become of Mary were he indeed to perish. Not until early September did Shelley recover, yet his general gloom lingered; after all, there had been a death earlier that year—that of the couple’s first child. Having moved with Mary into a cottage on the border of Berkshire and Surrey, a hundred yards or so from the Great Park at Windsor, Shelley wrote the death-inflected “Alastor; or The Spirit of Solitude” and a work that more directly addressed his anxieties about his future wife: a Gothic, angst-ridden poem called “The Sunset.”
more here.