There are so many factors to consider. Maybe the bottom line is . . .
You can make it a safe and healthy environment for you and your kids.
Once, there was a secure attachment, i.e., connection between you and your partner.
End it if:
You tried everything in your control to make this work, especially because you have kids.
You are certain that you would rather be alone the rest of your life than live in this relationship.
There are repeated patterns that break your trust such as domestic violence, harm to kids, severe untreated mental illness.
This all sounds so cut and dry. It is not. You have no control over your partner. Look in the mirror and face yourself, deal with your issues, 'fess up to your human messes. While it won't be fun, you get to keep your growth and progress no matter what you decide.
Let me expand on those lists briefly (they could fill a book).
1. You can make it a safe and healthy environment for you and your kids. This means that your genuine self has a place in your home. You do things that nurture you and add to your well being. Your kids have a parentally respectful home to grow up in. They are likely to grow up and treat their partner the way(s) they see you treating each other. Hopefully, you and your partner will get the help you need to live a happy life together; meaning what goes on between you in the home.
2. Once there was a secure attachment, i.e., solid connection between you and your partner. In your early years together you gave each other support and attunement (not fixing); you knew s/he had your back no matter what; you sought comfort and sex from each other; your home was a haven that gave you the energy to face everything outside your door. If you had that, there is hope that you can have it again.
Then stay and work on your relationship.
1. You tried everything in your control to make this work, especially because you have kids. You've read the books on my reading list. You've been to individual and couples counseling, you've closed the door to outside emotionally intimate relationships with your "friend," you've put your concerted time, effort, and money into resolving your personal and inter-personal issues. You tried to make it work with all you've got. And still you want to end it.
2. You are certain that you would rather be alone the rest of your life than live in this relationship. Really. Also note that wherever you go, there you are. This means that you will bring your own issues into another relationship, likely choose another mate that is similar in many ways to your current mate -- and you will not be able to see that for at least two years or more. I am not trying to depress you here, just painting a picture for you.
3. There are repeated patterns that break your trust such as domestic violence, harm to kids, severe untreated mental illness. These are deal breakers because you (and your kids) are not safe. Leaving a harmful relationship is tricky and may be dangerous. Get help from a domestic violence hotline BEFORE you begin your getaway plan. Leaving these relationships often becomes the most dangerous time of all.
Then end it.
If there are children involved, seek professional support to help with your decision. If it is just the two of you, professional support is a great idea, too, since you will have someone in your court that has your back and will ask the tough questions.