Contrary to popular belief, the terminally ill do realize they are going to die, and often times, they don't want your help "coping". Trust me, one of the worst things a terminally ill patient hears on a regular basis is, "How are you feeling about all of this?"
I know this because I am considered to be terminally ill. I also know that I'm perfectly comfortable with it. I am one of the people that you meet that is not afraid of dying and that isn't just since I was diagnosed either.
Families of the terminally ill usually need more help than the terminally ill themselves. It appears that the families hang around in the denial stage until they are shocked out of that, often they simply lie to themselves about what's going on until they are forced to face it. If you know a family member of someone who is terminally ill, you should speak with them, most assuredly they will either a) fall apart or b) claim that things are going really well and they are fine. It's the people that fall into the second category that need to talk about it the most.
It's really important to be open, honest, and listen. Whether you're talking to the patient or the family. Ask questions if you don't understand, generally the person who is ill is more than willing to fill you in. What you shouldn't do is act pitying, especially not to the patient. We don't want your pity. If you want to listen to us, great, but please do not say "awww, I'm so sorry." Think about what you're saying, are you sorry or are you just happy it isn't you or your spouse? That probably seems quite unfair but if you think about it, it's true. It's a bit like saying the dead "look so peaceful" when really, they just look very dead.
The families of the terminally ill and the patients too, tend to run through the normal stages of grief. Expect a terminally ill patient to suffer from depression and isolate themselves, usually it does end eventually. When they are isolating themselves, try to make contact, but don't force the issue. When the family or the patient decides to do something off the wall and you just can't understand it, smile and know that they are doing something important to them for whatever their reason.
The most important thing about dealing with the terminally ill is to remember that it is okay to laugh about it. When your terminally ill friend is at a party at your house with their spouse and they joke about scouting members of the opposite sex to replace them when they die, laugh along or at least smile. There's nothing worse than someone who can't take a joke.