I suggest you begin with the Talmud's Mishna Kiddushin, and (much easier to follow) the Laws of Marriage from Maimonides' Code.
The halachic status of being married is terminated, permanently, from that moment on, upon either death or divorce. Not paused, not retroactively voided (except for a few very odd cases).
People misunderstand "contract" -- there simply is a halachic status that the couple is married; death or divorce end it. Doesn't matter what they agreed on.
The Ketubah is something entirely different, a financial document -- he agrees to pay her a large sum of money in the event of divorce or death (in which case the payment comes from his estate). That is therefore enforced like any other financial agreement, upon those triggering conditions. (And as "equitable distribution" often means she'll get more than the sum in the Ketubah, in most divorces today that's what's done instead. The financial obligation can be waived.)
Now if someone promised their dying spouse that they would do XYZ (or not do XYZ) ... that's addressed by halacha too -- please ask it as a separate question. (But the law would be exactly the same if they made a promise to a parent, a friend, or some random stranger.)