Courts generally award custody to the surviving biological parent when the custodial parent dies. An exception to this rule is if the court considers the surviving parent “unfit.” State guidelines determining the types of behavior that make a parent unfit vary, but a judge may deny your bid for custody, for example, if you have a history of drug use or child abuse. Another situation in which the court would not award you custody upon your ex-wife's death is if your ex-wife remarried and her new husband adopted your child. A stepparent adoption typically terminates the biological parent's rights, including the right to receive custody upon her death.
If your ex-wife had a will, her will may stipulate who she feels should receive custody of the children upon her death. Because children are not property, your ex-wife cannot legally bequeath the children to anyone. The court will, however, take her request into consideration when determining custody. If you choose not to accept custody of your children following your ex-wife's death, that does not mean that you can no longer see them. Provided your parental rights were not terminated, you can file for visitation rights and continue spending time with your children regardless of who receives custody.
Small children are not capable of making major decisions for themselves, such as who they prefer to live with after their mother's death. Older children, however, can decide on their own whether they would prefer to live with you or a different guardian. Each state has its own guidelines dictating how old a child must be before his opinion on his own custody arrangement carries weight with a judge. If your children are old enough to make such decisions in your state and opt for a different guardian, the judge may honor their preference.
In some states, such as California, custody automatically transfers to the non-custodial parent should the custodial parent die. If custody automatically transfers to you, that does not guarantee that the arrangement will go uncontested. If your ex-wife did not stipulate in her will that you should have custody of the children upon her death, or noted her preference for a different guardian, others may petition for custody.