courts should contact child services,
the other parent who shares custody (joint custody)
automatically gets custody,
no application for custody is required as they already have custody,
just an amendment to the custody papers.
the ex wife can have a lawyer represent her to ensure it is temporary custody.
If the courts failed to pick up on the fact the children are without a designated supervisor the other parent can notify child services and they will intervene.
Courts are inclined to keep custody with parents as often as possible
Hence the reason so many irresponsible parents manage to get their kids back over and over again...it is the courts mandate to keep families together whenever possible.
Not sure where you live...I have worked in the ontario family courts and jails for years...American law is similiar.