Praise be to Allaah.
If the relationship between you and them is as you describe, then adhere to the Book of Allaah and the guidance of His Messenger (peace and blessings of Allaah be upon him). Try to advise them, enjoin upon them that which is right and good, and forbid them to do that which is evil. Be patient in bearing their insults and harm, and do not let their insults deter you from carrying out your duty towards them, which is to enjoin what is good and forbid what is evil. This is the way of Allaah concerning the callers and those who are called. Allaah has explained that in the aayah where He tells us that Luqmaan said to his son (interpretation of the meaning):
“O my son! Aqim-is-Salaat (perform As-Salaah), enjoin (on people) Al-Ma‘roof(Islamic Monotheism and all that is good), and forbid (people) from Al-Munkar (i.e. disbelief in the Oneness of Allaah, polytheism of all kinds and all that is evil and bad), and bear with patience whatever befalls you. Verily, these are some of the important commandments (ordered by Allaah with no exemption)”
If you fulfil your obligation of advising them, and you do this repeatedly but do not find any way to reach their hearts, or they cling more stubbornly to their falsehood, then withdraw from them lest you become weak in your religious commitment and moral standards, or their influence over you leads to bad consequences. Be sincere towards Allaah and Allaah will help you. Do not worry about feeling lonely if you leave them, for loneliness is better than bad companions.
“And whosoever fears Allaah and keeps his duty to Him, He will make a way for him to get out (from every difficulty).
And He will provide him from (sources) he never could imagine. And whosoever puts his trust in Allaah, then He will suffice him. Verily, Allaah will accomplish his purpose. Indeed Allaah has set a measure for all things” [al-Talaaq 65:2-3 – interpretation of the meaning]