All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
If you endeavored in advising those who commit evil, and they did not respond to you, then by admonishing them, you have acquitted yourself from sin. Nonetheless, if you are unable to stop that evil, you must not sit with them. You must leave them and go to another place where you do not see that evil; Allah Says (what means): {And it has already come down to you in the Book that when you hear the verses of Allah [recited], they are denied [by them] and ridiculed; so do not sit with them until they enter into another conversation.} [Qur'an 4:140]
If you leave that room and sit in another room in a way that you do not see that evil, then there is no harm on you.
Allah knows best.