Reference: as-Sahwah al-Islaamiyyah – Question 61, Page 197
Question: My colleagues at work are always talking about sex and pornographic magazines, and I advise them against this, but with no effect. So what should I do?
Response: If your advice does not [encourage] change in these people who talk haraam speech, then that which is obligatory upon you is to leave this job [and move] to another job. This is because sitting with sinners whilst you have the ability to leave them is considered taking part in their sin, as Allaah (Subhaanahu wa Ta’aala) says:
{And it has already been revealed to you in the Book (this Qur.aan) that when you hear the Verses of Allaah being denied and mocked at, then sit not with them, until they engage in a talk other than that; (but if you stayed with them) certainly in that case you would be like them}, [Soorah an-Nisaa., Aayah 140]
So that which is obligatory upon you if you are unable to achieve a change in their ways, is to find a different job so that you don’t take (are not considered taking) part in their sin. And Allaah knows your intention, that you are trying to flee this haraam [act], and He will facilitate for you your affairs, as He says:
{…and whosoever fears Allaah and keeps his duty to Him, He will make his matter easy for him}, [Soorah at-Talaaq, Aayah 4]
And He says:
{And whosoever fears Allaah and keeps his duty to Him, He will make a way for him to get out (from every difficulty)}, [Soorah at-Talaaq, Aayah 2]