First if of course it depends on the child's age. The child should at least be able to understand and communicate in return to the parent telling him/her what is happening - so maybe 7 or 8y/o up? And then on when, I think best if the parent telling it has already taken him/herself time to settle down thoughts and not when the heat is still up and he/she's already weighed things out.
To tell the reason why, that's actually hard to tell because there are million possible reasons and not all are worth sharing especially if it will somehow cloud the child's future to having the chance to live at least like normal. The telling parent for sure knows how much her child can handle and how possibly the kid would react, so totally depends on that.
In this article I've read, there are some steps presented on how to still try compromise things help in terms of raising a child who lost to witness her parents' living on their vow to stay together: https://ph.theasianparent.com/co-parenting-single-parents/
Shiela Espares Ballester