Hello Angela, welcome to the forum.
Since this is an Islamic forum, I think you are asking about custody on children after divorce (Hadhanah) according to Islamic law.
According to Islamic Law Compilation that used in Indonesia, if divorce happen, then the custody comes into the mother because the mother is the party that gave birth the children, and she has special closeness with the children.
And if then the mother dies, the custody turn into (based on the sequence)
1. Grandma from mother side.
2. Father.
3. Grandma from the father side
4. The child older sister.
5. Female relative from the father side.
This is if the child is under 12. Children who have reach 12 years old can decide to live with the mother or the father.
However, this rule is not absolute. If the judge in Sharia court consider that the mother is in condition that unable, or not 'in good condition' as a mother, such as she has very bad behavior, the judge can decide to give custody to the father.