Reference: Fataawa Noor ‘alad-Darb – Question No.6421, Page 249, Volume 12
Question: Is it prohibited for a person to remain in a place where reprehensible acts are taking place?
Response: Yes, it is not permissible for person to remain in a gathering where reprehensible acts are taking place, unless he is able to put a stop to it, in which case he must remain there until he has put a stop to it. If, however, he is unable to do so, then he must leave that place; this is based upon the statement of Allaah (Tabaaraka wa Ta’aala):
…meaning that if you remain [there], then you are like them in sin.
So it is obligatory upon the person to detest the reprehensible act according to his ability; and this is based upon the saying of the Prophet ﷺ:
And it is absolutely not possible for a person to detest [a reprehensible act] with the heart and [then] continue to remain in the place where it is taking place; that is because to detest with the heart is to dislike the reprehensible act, and to leave the place [where it is taking place] if he is unable to put a stop to it.