I recently watched Saw 7 that had the ending totally different from what I thought as expected from its story line which I really didn't like.
Is there a term for such an ending where it doesn't happen what we were expecting and it's unsatisfying?
Specifically, it's a sub trope of Plot Twists called a "Twist Ending".
A plot twist can happen at any time in the film. When it happens near the end to change the meaning of the entire film, it is a twist ending. The idea is to lead the audience on throughout the film then when they least expect it, flip the script on them only at the end.
An anti-climax is exactly what it says, the lack of a climax as traditionally seen. In this case, the plot goes unresolved or is unsatisfying in its resolution. For example, the main villain escapes, no action scene, or the hero's denied emotional closure. It is not what you think. It's basically a failure in literary scope.
I guess you're referring to a plot twist. From the wiki:
A plot twist is a radical change in the expected direction or outcome of the plot of a novel, film, television series, comic, video game, or other work of narrative. It is a common practice in narration used to keep the interest of an audience, usually surprising them with a revelation. Some "twists" are foreshadowed.
Another type of ending that fits the more 'out of the blue' nature of your question is the Gainax Ending
A Gainax Ending is an ending that doesn't make any sense, or does make sense but is hidden under enough Mind Screw to not have an easy explanation. This is usually a deliberate form of Mind Screw or intended as a Sequel Hook to a sequel that was never made. If it's not done intentionally, it's often the result of the creators rushing to meet a Cosmic Deadline.
Gainax endings are usually unsatisfying because they come from left field and usually result from lazy writing (see also: Deux Ex Machina). However, they can be done quite well, especially in comedy. See: Monty Python and the Holy Grail.
Twist is a good answer, but also you have an Asspull.
An Asspull is a moment when the writers pull something out of thin air in a less-than-graceful narrative development, violating the Law of Conservation of Detail by dropping a plot-critical detail in the middle, or near the end of their narrative without Foreshadowing or dropping a Chekhov's Gun earlier on.
Because you mentioned 'unsatisfying' I'm just going to going throw in the term 'Deus ex machina' out here as well.
"An unexpected power or event saving a seemingly hopeless situation, especially as a contrived plot device in a play or novel."
In Greek plays, it's often (and literally) referring to when an all powerful god steps in and saves the day.
Modern film examples could be the bacteria that suddenly saves the day in War of the Worlds, or the giant eagles who swoop Frodo away at the end of the Lord of the Rings, or Superman simply reversing time in one of those movies.
They're just easy and unsatisfactory ways of ending the film in one scene.