On a stormy night, Bart tricks Lisa into playing The Scary Maze Game and posts a photo of her surrounded by his dirty clothes on the Internet. At dinner, the line gets hit by lightning, cutting the family off from it.
To pass the time, the family digs up their old VHS player, but when it breaks, Bart and Homer go to Ned Flanders' house to steal his router. Bart climbs the ladder to the attic, but gets hit by lightning and falls into a coma. Because he scared her earlier, Lisa gets revenge on him by giving him nightmares.
He wakes up in his bed as the ghost of Maude Flanders arrives, scaring him. Next, she sends in Milhouse Van Houten while he decorates Bart's treehouse with crosses to keep ghosts out, thought that does not work as Maude's ghost returns, but Bart scares her off with Homer's socks. Milhouse suggests Bart talk to his psychiatrist Samuel Elkins, but it turns out he is a ghost too, and Bart helps move on to the afterlife.
More ghosts of the show's deceased characters appear asking him for help, which he does. Lisa, though, continues to give him nightmares until Doctor Hibbert advises her to stop. Bart agrees to help Maude, who wants revenge on Homer for causing her death. Jimbo Jones, Dolph Starbeam and Kearney Zzyzwicz kill Homer by firing shirts at him. To avoid Homer going to Heaven and causing his own death, Bart shoots a shirt to the light of Heaven, shutting it off.
Shortly after, Bart wakes up and tells Lisa he has discovered how everyone will die: