To OP: Nice that things went well.
Generally speaking I don't like situations where players are imprisoned/threatened with political stuff/get to court for judgement. They are usually bit boring, and many DM:s I've played with kinda get negative reaction from players. They are not bad plot ideas, but most players like "freedom".
As what some other posters said when to loose your character, I don't think you ever should. It's basicly same as kicked out of game. You can loose your character because of death and sometimes because of some nasty corruption (that equals death as far as game is concerned). And if game allows resurrection so should it allows to "cure corruption" if remaining pc:s are ready to use the money/put up the fight for their lost partner. Especially if situations where unwilling. If player willingly chose to do something "evil" might be party doesn't that traitor back, but if they want why not.
When you say "if you don't play my adventure the way I planned your character is out" can sound very different how you say. When everyone is aware that you are playing "some pre-planned adventure" and "dm is not just making it up we go along" players should respect that. If situation is unclear/unwanted to players, all kinda blaming and crying will occur.
If you made it clear at beginning "going evil" is not allowed, you should not put players to face situation where "evil choice" is actually better one. Especially if you are apprahended by some workers for (not-so-trusted-by-pc) nobility etc. Violence does seem easily more sensible. PC:s are not reading your mind, it's all about impressions. And don't try to corrupt pc:s on purpose if going non-good is end to their character. Not every player likes such an unfair social manipulation.
A DM has the right to say I don't want to DM a game with evil PCs. A DM should not be forced to do it if is something they really dislike. And if the players know this going into the game then as I said before if they still make the choice to be evil then they know the consequences.
As a DM I set up encounters and I set them up in a way that the players have several choices on how to proceeded. I would never set up an encounter where the only way out is for the PCs to do an unspeakable act.
But I see nothing wrong with making the evil choice the easier choice instead of the good one. Part of being a hero is to make those choices.
In my game the party knows that the bad guys are looking for a baby girl. She is part of a prophecy and is needed to open the way to allow Tiamat back into the world. But she has to be sacrificed at certain time for this to work.
The party knows who the child is and they just protected her from the evil guys kidnapping her. They know that certain orders thinks it would be better to kill the baby now.
It certainly would be the easiest thing to do and it would be cold blooded murder and an evil act. There are other ways of stopping Tiamat besides killing the baby.
There is a big difference between magical corruption and mind control and a PC deciding that evil is an easier path to walk or more rewarding.