I just wanted to know what Islam teaches us as to how to deal with toxic family members who deliberately hurt you with their words

You have to maintain ties with them, however you are not required to spend so much time with them.