The Talmud warns us to be careful not to stand in a dangerous place. If this is true with physical dangers, all the more so we should be careful not to be in situations where one's soul is in danger.

Stay away from dangerous spiritual situations. Don't purposely battle your evil inclination face-to-face. Keep as far as possible from any potential temptation to do something improper.