Just curious....

I don't want to be morbid, but have a question. Do soap opera writers write their stories in a way that can give them an out should an actor or actress suddenly die or be unable to continue filming? Would the soap continue to air the already filmed scenes after a death of an actor or actress? I been kind of watching the show again and notice some of long time cast aren't getting any younger. I'd imagine some of the newer cast members roles might get recast, but you can't recast Victor Newman or some other iconic, long term characters.