The key difference between a rug jerk ending and a surprise twist ending is that on reflection or a second reading, the rug jerk still doesn't make sense.
It isn't something readers like though. It's disorienting, unsatisfying, frustrating, and fortunately doesn't usually make it through the publishing process. It also betrays the trust that the reader gave you - to tell a tale that is true to its own logic all the way through. Even seeming exceptions to the rule often aren't: for example, the Hitchhiker's Guide to the Galaxy has an internal logic that says that if it's absurd, improbable, and completely ridiculous, it'll probably happen. The discworld series follows the rule that "million-to-one chances happen nine times out of ten." They are true to their own structure.
Fortunately, a rug jerk is fairly easy to spot. Just read the whole story, and if you can't explain the ending in terms of the story logic, it probably needs to be fixed.
The rug jerk is somewhat related to the Deus Ex Machina as they share a complete lack of foreshadowing. Instead of a previously unmentioned talent, object, or person suddenly appearing to save the day, a rug jerk uses an event that wasn't set up or even hinted at earlier in the story to change everything. Sometimes, if the author is aware on some level of how disjointed the rug jerk is, a character will express that by commenting on how unbelievable it is - but that's a symptom, not a fix. ("I wouldn't believe it myself if I hadn't seen it!" won't make the reader believe it...) Remember, just because life doesn't make sense doesn't mean a story doesn't have to.
Fixing a rug jerk is easy to summarize, but not as easy to actually do - and it depends a lot on both the story and the author.
If you're convinced that the ending must stay, then you'll want to go through your story and plant hints throughout, so that the ending can be explained by the story logic. If you're willing to change the ending, then you'll want to go through your story looking for hints that, when taken together, suggest an ending. You may find some excellent foreshadowing already there - like themes, a pattern of hints has a way of sneaking into a story without you noticing at the time.
Or you could do a combination of both - see what endings suggest themselves and add hints as necessary to support the one you choose.
Just remember not to take the first idea you have without looking at a few others too - usually the first idea to show up is the obvious (and predictable) one, and obvious and predictable is what you were trying to avoid in the first place!
1. Credit where credit is due... I didn't come up with the term "rug jerk" for this plot error. I first read it in the turkey city lexicon, a very entertaining and entirely correct list of common plot, characterization, and setting errors. It's written for SF, but many of the items are applicable to all genres.