A woman will live for 5 more years. She already has three kids at age 2, 5, and 7. In this scenario it is very likely the reduced resources these kids will have from sharing with a new sibling will reduce their chance to survive more than the 5 year old motherless child will add to the expected number of descendants.
You could argue that it would be better if the genes considered these scenarios better and adapted. But genes are very crude, they can't encode for all those things, so instead they just do what is best in the typical scneario.