You can work with your ex without flipping out.

Just look at “Flip or Flop’s” Tarek and Christina El Moussa. They’re pros at turning distressed properties into prime real estate – and they’ve also managed to salvage their working relationship even as their seven-year marriage ended.

The reality stars and parents of two young kids separated last year, but they’re still producing the seventh season of their hit HGTV series. They’ve also teamed up to create “Chi-Town Flip” and other upcoming shows with their Sky High Media production company.

“To be honest, it has been tough. And we have had our moments,” Tarek admitted to Variety. “[But] we are going to work together as parents for the rest of our lives. In business, we are continuing to film ‘Flip or Flop’ and are conducting our real estate seminars together … We’ll just have to see how things unfold.”

Considering almost half (41%) of Americans have dated a coworker, according to a CareerBuilder survey, plenty of us have found ourselves in the same awkward position as the El Moussas. And 5% said they had to leave a job after a relationship went sour.

If you can’t keep the personal stuff outside the office, you can’t work with an ex. (AntonioGuillem/iStock)

And yet, some old flames have managed to keep clocking in together without clocking each other out. Take Dolce & Gabbana power couple Domenico Dolce and Stefano Gabbana, whose romantic relationship ended in 2005 after 23 years together, yet the luxury brand is still working the runway. Or “The Big Bang Theory’s” Johnny Galecki and Kaley Cuoco, whose romance ended in 2010, but their onscreen characters have stayed together and even gotten married.

This backs new research by the University of Kansas, which finds that exes who stay friends for practical and civil purposes – like financial reasons, or sharing children – had the longest and most positive friendships over those who tried staying friendly for security reasons, or because one still had feelings for the other.

Cooper Lawrence, relationship expert and host of “The Cooper Lawrence Show” on 101.6 BLI, told Moneyish that she even sometimes hires her ex-husband to write for her radio program.

“You can be friendly without being friends,” she said, noting that the key to making this work is establishing clear personal/professional boundaries and setting job responsibilities.

“When somebody is your ex, you feel like they should know what you want or how you like something done, but that’s not always the case (you did break up, after all),” she said. “You need to treat your ex like somebody you just hired, and be very clear and upfront.”

Moneyish tapped Lawrence, New York-based relationship therapist Rachel Sussman and CareerBuilder.com senior advisor Michael Erwin for their Dos and Don’ts to working with an ex.

Do set boundaries. Be very clear about who is working on what, and work in different parts of the office to create actual space between the two of you. “It helps to have a job description of what you’re each covering, and to even work in different parts of the company so that you’re not all over each other,” said Sussman.  Lawrence agrees you need to focus on the job at hand. “There’s money and livelihoods at stake here,” she said, “so you need to make sure the rules are there so you both can succeed.”

Don’t socialize together. Going to happy hour with colleagues or taking clients out together risks blurring those personal/professional lines again. “You have to limit that, because socializing often leads to jealousy,” said Erwin. Plus, alcohol can also stir up old feelings, so it’s best to take turns hitting up or hosting those events. And discuss whether you’re going to be upfront about when you’re dating other people, or if you’d prefer not to know about it.

Do have something to work toward. Setting career goals – like trying to meet a sales quota or launch a project – can get you both on the same page again. “If you both work toward those clear goals, it becomes a lot easier to work together than if you don’t have goal, and don’t have professional expectations of each other,” said Erwin.

Don’t overshare. Making your relationship “complicated” on social media is going to complicate things in the office, too. “Your coworkers will see that, and the gossip about your relationship can be worse for productivity than if you two are actually fighting in the office,” Erwin said. “You really need to make sure when you’re at work and when you’re online, that you’re as professional as possible.”

Do get a mediator. “Designate someone impartial that you both trust to be the tiebreaker when you can’t agree on something in the business,” said Lawrence. That could be an HR rep or someone in the company, or a trusted third party like a counselor or therapist.

Don’t carry a torch. “If one of you is still in love with the other, this is never going to work. That’s the deal-breaker,” warned Lawrence. “Those feelings are always going to come out, and your business is going to suffer. You have to be ready to move on, or have already moved on.”