Warning: The following contains spoilers for Doctor Sleep, in theaters now.

Doctor Sleep spends most of its run-time trying to escape the shadow of the Overlook Hotel. While the film primarily centers on Abra's (Kyliegh Curran) attempts to stay ahead of Rose (Rebecca Ferguson), Dan Torrance (Ewan McGregor) is eventually forced back to the Overlook Hotel to confront the (literal) ghosts of his past.

In the process, the filmmakers actually find more to draw on from the original ending of Stephen King's novel The Shining instead of Stanley Kubrick's iconic adaptation of the ultimate haunted house story.

RELATED: Doctor Sleep Is a Visually Stunning Love Letter to The Shining

HOW THE BOOK & MOVIE ENDED

Jack Nicholson's The Shining character has a sinister grin while in a hotel corridor

Stephen King's original version of The Shining ended differently than the film version that was directed by Stanley Kubrick. In the original novel, Jack Torrance is driven mad and possessed by the spirit of the Overlook Hotel. But before he can kill his son, Jack is able to regain some semblance of himself, which gives Danny the chance to run. The Hotel is able to take over Jack again, destroying what remains of him in a rage and destroying his mind. That's when Danny reveals that Jack had never adjusted the pressure on the hotel's boilers, which genuinely unsettles the entity.

If the pressure isn't vented, it will explode and destroy the hotel. Jack rushes to the basement, which  saves Danny, Wendy and Hallorann, who actually survives the events of the book. However, he is unable to stop the boiler, and the resulting explosion kills Jack instantly and destroys the Overlook, seemingly ending the spirits that were within it. It's an all-together happier ending than the movie, which ends on a much more ambiguous and unsettling tone.

RELATED: The Shining: The True Story & Real-Life Hotel Behind The Movie

The film ultimately ended in a similar place -- with Jack dead and both Wendy and Danny alive -- but it got there in a very different manner. Hallorann doesn't escape the Overlook and is killed by Jack during his attempted rampage, and the boilers were removed completely from the film version of the story. This means that there's no fire to destroy the Overlook Hotel in the end. Instead, Jack is killed by winter after chasing Danny into the topiary maze on the grounds of the building without any winter wear.

Danny tricks him and is able to escape the maze to reunite with his mother. Meanwhile, Jack is lost in the snow and quickly overcome by the cold, freezing to death by the time of the sunrise. The Overlook Hotel remains standing. Jack Torrance even seems to have been absorbed by the power of the Hotel, with his visage appearing alongside the other souls in the enigmatic photograph at the end of the film. It leaves the movie on a less happy note, and even somewhat seems to imply the Hotel will continue to be its malevolent self for whatever poor soul becomes the next caretaker.

THE END OF THE OVERLOOK

Doctor Sleep draws far more from the book's original ending than the film, although it uses the basic structure to create something new. The disused Overlook slowly comes to life after the arrival of the now-grown Dan Torrance. He even speaks with the spirit of his father, which has been absorbed by the Hotel and become the new version of Llyod the bartender. But the Hotel really comes back to life when Dan unleashes the various spirits that he'd been containing within his own mind. Returned to their home, they make quick work of Rose the Hat before turning on Dan and possessing him in much the same way that his father was in the book.

He's even able to briefly break through the control to speak to Abra, who he's been chasing through the Hotel as he once was in the novel. She's also the one who tells the Overlook (as it regains control of Dan) that the boilers have been set to blow. As the possessed Dan runs to the basement, Abra makes her escape. This is almost exactly what happens in the book, although the failure to vent the boiler was more due to the accident than any intended result. Dan is also able to break free of the Overlook's influence on his own to keep himself from stopping the boilers, which allows him to die as himself. This wasn't the case for the book version of his father, whose mind had been completely taken over by the Hotel by that point.

However, the end result is still the same: the boilers explode, killing the Torrance in the room. The fire quickly spreads and burns the Overlook Hotel down to the ground, seemingly destroying the dark presence that had been feeding on people for decades. However, it's revealed that at least some of the spirits (notably the decaying Old Woman) still managed to escape the destruction and were able to latch onto Abra in much the same way they'd stuck with Danny throughout his youth, allowing the film to end with some ambiguity towards whether the evil of the Overlook has truly been stopped.

Written and directed by Mike Flanagan, Doctor Sleep stars Ewan McGregor, Rebecca Ferguson, Kyliegh Curran, Carl Lumbly, Alex Essoe and Zahn McClarnon. It opens Nov. 8 nationwide.

KEEP READING: How Doctor Sleep's Shining Scenes Compare To The Original Movie