My understanding: Twists, whether good (for protagonist/s) ones like deus ex machina or bad (for protagonist/s) ones, are bad (in writing) if they could not have been seen as plausible with prior information (In case relevant, do not assume the converse is true). Examples would be twists that involve violation's of Knox's 10 Commandments or twists that are 'insulting to the reader' from the Family Guy episode 'Three Kings', based on Stephen King's works.*
(*) Here, Stewie presents examples of twists that are bad (in writing) and good (for protagonist/s).
Stewie: No, no, no! This won't do, Paul. You can't just have Snuggly Jeff magically brought back to life by a child's wish. It's insulting to the reader!
Paul: What do you mean?
Stewie: Well, it's just bad story telling. Let's see ... How can I explain this to you? Did you ever see the movie Contact?
Stewie: So, like, they spent a trillion dollars building this mile high space machine and Jake Busey blows it up. So, now they're all like: "Oh, no. We can't use the space machine,” but then this other guy's like: "Hey, it just so happens, I built another identical trillion dollar space machine at my own expense, on the other side of the world." And we're supposed to believe no one noticed that? Well, I stood up in the theatre and I said: "No! You can't go into space because the machine already got blown up by Jake Cock-a-Doody Busey!" [throws papers in trash] Start over