Nothing wrong with crying in front of kids... at a funeral, watching a sad film, listening to music that reminds you of a lost loved one, when a pet dies, at the theatre, with joy/happiness, when a natural disaster occurs or over a war or other horrible event, when receiving bad news, when something treasured gets lost or broken, or occasionally out of relief or frustration.
But this does not sound like a passing thing, this sounds like a bigger ongoing issue. And honestly mental illness can be so scary for kids. They are probably creating some distance because they done know how or behave, are scared of saying or doing the wrong thing, and your ex is the easier one to go to because he seems to be handling his shit. It can be scary for our kids to see us get vulnerable and emotional, but also healthy for them to know we are human, but to see us fall apart? That's terrifying. They need us to be strong, stable and resilient, we are their shelter in the storm, their safe port, their sanctuary. And when we cannot be that they will go elsewhere for their stability and security needs. They need to. It's not personal, it's survival.