The Bible says that “Bad company corrupts good character” (1 Cor 15:33). What this means is that if we spend a lot of time with people who do not please Jesus, evil spirits and other negative influences can move from others to you.
This is why the Bible also says that we should “abstain from every form of evil” (1 Thess 5:22) and also that “Whoever walks with the wise becomes wise, but the companion of fools will suffer harm” (Prov 13:20)
So when people are speaking bad language, gossiping, making rude jokes or engaging in any other sin, Christians should move away from such people. You can excuse yourself to the bathroom or go and get some water.
Sometimes though, this can happen during a class or in a meeting (where you can’t leave the room). What we should do then is, as soon as we can, we should pray and cast all these things out from us.
If you find that you can’t leave because your heart or mind want you to stay amongst such people, then you need to command them to obey Jesus.
You can pray:
“In Jesus Name I command my heart and mind to reject every form of evil and to cling to Jesus Christ alone. I cut every soul tie with other people or the world and I command every evil spirit of (mention the sin – example: gossip and backstabbing) to go from me and not to return in Jesus Name. I receive the spirit of humility and obedience to Jesus. Lord I want to please You alone and I want to humble myself to Your Word. I command my heart and mind to meditate on spiritual things that please Christ“.