Over the years, I've known of a few families who have suffered a tragic loss. In one family, a husband was involved in a car accident on the way home from work and died instantly. His children went to the same elementary school as my children and I remember how sad I always felt whenever I saw his wife at school functions after his death. I also remember how I would intentionally try to avoid her because I didn't know what to say when we crossed paths.
I do now.
You don't really need to say anything. Just say your sorry for their loss or just be there.
Don't say how shocked you are. Anytime someone said that to me I felt like saying "no shit Sherlock."
Don't say how exactly the same thing happened to you unless it really did. Without trying to be insensitive, losing your mother at age 77 to a heart attack is not the same thing as losing a wife at age 45 to a heart attack.
Don't say give me a call if you need anything especially if prior you haven't talked to each other for many years or if you had never shared a close relationship. The person(s) going through the tragic event is still trying to process everything and doesn't know what he/she needs or who to call. If so inclined, just show up and do the dishes, take out the trash, do a load of laundry, make a grocery store run. Be available to talk but only if approached.
If you have never really shown yourself to be a spirit filled individual don't say you are keeping us in your prayers constantly. I would prefer you just say we have been in your thoughts-even if I know it was probably only a very fleeting thought. I completely understand.
Of all the things said I so appreciated these two:
My 93 year old neighbor said "there are no words to express how I feel."
A former colleague who had lost his wife a number of year ago said "please know that eventually you will find the light at the end of the tunnel in which you find yourself in at this time."