If the villain is really that much more powerful than the PCs nothing could stop him from leaving except for the DM.
The Fact of the matter is you do not put a foe 7 CR's higher against the party and expect everything to be fine. Not at level 1 at any rate. Yes the foe wasn't trying to kill the monster but you cant say the same for the other way around!
It's just bad design.
Just like the way Frodo charged in to Mordor and killed Sauron.
Or not.
D&D has never been just about that.
Sounds like your party learned a valuable lesson, just because someone may need killing, doesn't mean it's up to the party to do the killing.
I guess that in my games, the players know to be careful. To me, Curse of Strahd is even "worse" (or better, depending on your POV) in this regard. A misjudged encounter early on almost resulted in a TPK and set the tone for the rest of the adventure, too the point that even foes they can not mop the floor with--they will be very careful about engaging. They don't take things for granted.
If the adventure doesn't telegraph this heavily, then a single-round TPK so there is no chance to reverse and get out is straight up bad design.
And in general, a foe running telegraphs "I don't want to fight you", of which the most common reason is they think they'll lose. So it needed to be unambiguously well shown to turn around that expectation.
Iirc the villain has plane shift no components so... Yeah... Staying and killing was a choice.If the villain is really that much more powerful than the PCs nothing could stop him from leaving except for the DM.
Alternatively, the group could have talked this stuff out before starting play, with the DM explaining that this was not a "kill everything that moves" kind of adventure and the players buying in. Things as described by the OP only happen when there is a failure of communication about the intent and expectations of the GM and the players.