Why do I struggle so badly with taking care of a dying relative?
Honoring and acknowledging the feelings and parts of yourself that are protective is an important part of our being emotionally healthy. It is much like receiving validation when we witness something or do something that we later have acknowledged and "Witnessed" by another human. In this case, it sounds like the wounded part of yourself recognizes, based on your experience, that your grandmother was not a good person to you and this "Part" is trying to make sure you are reminded of that. So, that part of you that is hanging onto those feelings is perhaps waiting for that validation and that recognition that your grandmother did leave wounds. I would suggest an exercise to recognize and remind yourself (actually speaking to that protective part of yourself), that you are going to be okay and that she can no longer cause harm to you. You can do this by writing a letter from your older self to your younger self, so that the part of you that is sending signals to be careful, be aware, can stop having to waive that warning flag so much. You can let that protector part of yourself know that you are well aware of what is going on now and that your grandmother will not be on this earth much longer.
At the same time, you can choose whether or not you want to continue the visits with her. Can you bring someone with you that knows the history? Is it possible to have a genuine conversation with your grandmother so that perhaps she can free herself of guilt, if she is in that space; and that you can speak the truth to her. It is not uncommon to be able to have such frank conversations at the end of life stage if the person is fully cogent. We do walk gently here to recognize that she is now the vulnerable one, at least physically, and to walk that path carefully to not cause harm to her or yourself. Breaking the cycle of abuse is a tight walk and it sounds like you are trying to do that, but need to acknowledge to your protective part of yourself that you are up for the task.
It sounds like there are some anticipatory, complicated feelings of grief, which can include apathy, anger, regret, guilt and a potpourri of emotions. This might also occur after she passes. Think of how you can navigate this in a way that you can honor yourself and the emotion you still hold in reference to your grandmother, and at the end of her life, feel good about how you walked that walk.
If not already, you may want to consider working with a professional through that process.
Be gentle with yourself,