A step-parent or other family relative can petition "in the child's best interests" in Probate court for guardianship of the child or children. This will essentially give them full physical and legal custody.
If this is done in Probate court, it may take precedence over orders from Family court. Probate court is a "higher" court than Family court, and sometimes Family court orders will be ignored. You may want to consult with a "probate specialist" to find out what the proper course of action would be, and you will definitely want to discuss this with your attorney.
If at all possible, have the Family court compel both parents to enter an automatic "turn-over" of custody to the surviving parent into their wills. This may or may not help, but it can't hurt.
If you are the non-custodial parent, file for full physical and legal custody as soon as you find out that your ex has died. Consider having your attorney prepare the required paperwork in advance.
As with any custody issue, the matters can take years to litigate and resolve. Obviously, this can work for you or against you depending upon who died and who has (had) custody. By being prepared ahead of time, you'll have a better chance of making sure things turn out properly.
If you are the custodial parent and you do not feel the surviving parent would be fit to raise the children,
Decide who you would want to raise the children if you should die unexpectedly.
"Will" guardianship of the children to the person you want to raise them,
File a valid will, and have your attorney and the person you want to raise the children retain copies.
Also follow the steps below to ensure proper transfer of inheritable property to the children.
If the non-custodial parent dies, inheritable items meant for the children may end up in the hands of the custodial parent. Some custodial parents may interfere in one or more ways with the transfer of the property to the children, with the result the children don't get the property or may never even know it existed. To ensure that your children inherit the things you want them to have, follow these steps:
Decide what property of yours you wish to go to the child or children. Make a detailed list of what property goes to which child.
Arrange in advance with a trusted third party (friend, family friend or your attorney) to hold the property for the children.
"Will" the property to the trusted party, with the understanding that they are to hold or "own" the property until the child is old enough to receive it. This may be a day, a month, or several years. The time period is up to you.
File a valid will, and have your attorney and your trusted third party retain copies.