deter from

deter someone or something from something

to prevent or discourage someone or a group from doing something. We can't seem to deter them from leaving. They were not deterred from their foolish ways.