Meet them where they are
People often ask me what they can say to someone who is grieving, but also to someone who is dying. There is always going to be some awkward silence when it comes to those two conversations. My advice is to always meet them where they are at, not where we hope or want them to be.
What does that mean? I am sure there is a professional definition, which you can Google, but for me it simply means not to sugar coat, or skip around, or avoid, but instead to be straight up honest and allow someone to do the same. Asking, "how are you?" when you know they are not doing "okay," can make the conversation start a little bumpy. Whether they are dying or they are grieving, they want to talk about it (not everyone of course, but most) and they want to feel safe with their feelings even if it might be tough to hear. How are they? They are not okay... so skip that question.
If you truly want to help someone who is struggling, meet them where they are, acknowledge the elephant in the room, and simply say, "I am here if you want to talk about anything." Be prepared for two things; they might say no, and that is okay. But they also might say yes, which means you need to be ready to truly listen, to hear them, to validate their feelings and to simply ask how you can help them, without trying to make it magically go away... it won't magically go away, you know that and they know that.
So be honest, be present, hold space, and meet them where they are. That is how you can help.