One of the most overused devices to end a movie, especially if writers have written themselves into a corner, is revealing that the whole thing was in the protagonist’s head all along, or that it was all just a dream.

RELATED: A Clockwork Orange & 9 Other Movies With Completely Unlikable Protagonists

However, there are movies that play this card well, and given all the hints throughout certain movies, the fact that the events never happened can lead to a spectacular payoff. Whether it’s a sci-fi movie about a billionaire or a drama about a working-class criminal, the “all in his head” device has been used in some of the most inventive ways, despite how overused it may have become.

Click (2006): 6.4/10

Michael plays video games in Click

Of all the movies where it turns out that the entire plot that was based in the characters’ heads or ended up just being a dream, Click is the guiltiest of using the device as pure ex-machina without having to actually tie anything up.

As Michael Newman finds a remote control that lets him rewind time, fast forward time, turn down real-life noise, and just about control any aspect of his life, he ends up regretting ever using it after destroying his life. However, the end of the movie reveals that the whole thing was a dream after he fell asleep on a bed in a convenience store.

Vanilla Sky (2001): 6.9/10

David runs through an empty Times Square in Vanilla Sky

Though most other movies that use the dream twist fail to deliver a satisfying ending, what’s interesting about Vanilla Sky is that it’s revealed that David Aames is actually lucid dreaming, and he has the option of waking up anytime he wants. Instead, he decides to wake up hundreds of years in the future, and it’s a terrifically mind-bending sci-if movie.

However, knowing the meaning behind the term “vanilla sky,” which essentially means that when somebody has a great dating life, all those dates tend to merge into one, it’s pretty obvious that it’s revealed to be one big lucid dream.

Triangle (2009): 6.9/10

Jess is being followed by a masked murderer in Triangle

Triangle isn’t very well known, as it’s an Australian production on a micro-budget, but it does feature Liam Hemsworth and is an incredibly well-presented psychological horror movie that makes audiences think. The movie sees a group of sailers become stranded after a storm, only to find a questionably empty cruise ship in the middle of the ocean.

A bunch of random events occur, including most of the group getting picked off by a masked murderer. Jess returns home safely, only to find herself waking up on the same day with her friends still alive. However, the movie is such a mystery that it has inspired a ton of theories, including the fact that it might not be a dream, but a tragic time loop.

Jacob’s Ladder (1990): 7.5/10

Jacobs Ladder Tim Robbins as Jacob Singer in Head Restraint

Jacob’s Ladder is another incredibly well-known movie that uses this trope. The ladder is symbolic of the connection between heaven and earth, and as Jacob is on his death bed after fighting in the Vietnam War, everything that happens is actually him going from one realm to the other.

RELATED: Darren Aronofsky's Top 10 Films, Ranked (According To Rotten Tomatoes)

What’s also interesting is that the chemist who reveals the information about the ladder to Jacob is called Michael Newman, the same name as the protagonist in Click. So if audiences were aware of Jacob’s Ladder before watching Click, they would have quickly predicted the end of the Adam Sandler comedy.

American Psycho (2000): 7.6/10

Patrick holding an axe whilst smiling

With so many existing differences between the movie and the book, the one constant thread in American Psycho is Patrick Bateman. He picks off prostitutes and his peers alike in the most gruesome fashion. However, whether he actually does or not is another question entirely, as, like Pan’s Labyrinth, it’s completely ambiguous over whether he actually did it or not.

Though there’s an admission of guilt at the end, the person he tells laughs it off as a joke, but looking back at the movie, there are strange sequences that have been edited that make it seem like it was all in his head all along.

The Machinist (2004): 7.7/10

Christian Bale in The Machinist

The Machinist follows Trevor, a machinist who is dealing with all sorts of trauma, and there’s a reason for the insomnia that’s revealed at the end of the movie. To play the titular character, Christian Bale lost 60 pounds for the role.

Most of the movie was all in Trevor’s head, as it was his way of coping with a hit and run he committed the previous year, which was the source of his sleeping troubles. And after he turns himself in at the end of the movie and gets thrown in a cell, it’s the first time he sleeps in a whole year.

Black Swan (2010): 8/10

Natalie Portman in the black dress prepared to dance in Black Swan

Though Black Swan is a terrifying psychological thriller, it’s also an interesting and introspective look at how people will do anything to strive for perfection.

In the movie, Nina lost touch with reality in more ways than one, as not only did she kill herself, but she imagined everything that had happened with who she thought was her rival, Lily. Everything viewers saw happen was all in Nina’s head, whether it was the relationship she had with Lily, or the scene in which she murders her.

The Wizard of Oz (1939): 8/10

Dorothy and the Munchkins in The Wizard of Oz

This comes as no surprise, as The Wizard of Oz is quite literally the most popular movie ever made. Dorothy believes she’s whisked away to a faraway land in a tornado, then meets talking lions and scarecrows, and becomes the enemy of an evil witch and her flying monkeys. Like it was ever going to end any other way than by having Dorothy wake up!

RELATED: Guillermo Del Toro: 5 Reasons Why Pan's Labyrinth Is His Best Fantasy Movie (& 5 Why Shape Of Water Is A Close Second)

Even before the reveal at the end, it’s pretty clear that Dorothy is dreaming the whole time, as the characters in Oz have the same likeness to the people that Dorothy knows in Kansas. But the whole journey is still fantastical and colorful, and the ending is part of what makes the movie so timeless.

Shutter Island (2010): 8.2/10

Two detectives and a policeman stand on a cliff in Shutter Island

Just like any great horror-thriller, there are a lot of questions fans are still asking about Shutter Island. But one of the easiest ways to answer those questions, or rather to brush all those questions under the rug, is by just knowing that the whole movie takes place inside of Teddy’s head.

As audiences think they’re watching a detective movie that follows Teddy visiting an island, it’s revealed that he’s actually a patient of a mental institution, and he’s essentially playing detective the whole time. Though there are a lot of loose ends that aren’t tied up, it’s still a gripping movie, and with knowing the ending, there are some dead giveaways upon rewatching it.

Pan’s Labyrinth (2006): 8.2/10

Ofelia meets Pan for the first time in Pan's Labyrinth

Out of all the movies that end up being in the character’s mind all along, few of them do it in an ingenious and satisfying way. But Pan’s Labyrinth pulls it off so ambiguously that it’s left to the viewers to decide which reality is the real one.

Being a social commentary on war, Pan’s Labyrinth follows a little girl with a wild imagination, as she conjures up this bizarre world full of fauns and beasts, and in this world she’s a princess. However, in the “real” world, she’s the step-daughter of a war criminal and leads a horrible life. The end of the movie sees her die in the real world, only to be reborn in the “fantasy” world, but it heavily hints at the possibility of the latter being true.

NEXT: The Wizard Of Oz: 5 Things The Movie Changed From The Book (& 5 That Stayed The Same)