Just days before Mariah Carey's dramatic split from James Packer, the diva and her ex husband finally reached a settlement on their drawn-out divorce, confirms Us Weekly.

After almost two years of squabbling, Cannon finally signed divorce documents only a few days before Carey and Packer's doomed trip to Greece in September. That's odd timing!

In the settlement, the big-voiced songstress and the America's Got Talent host agreed on joint custody of their 5-year-old twins, Moroccan and Monroe.

They also kept the earnings they separately made during their six-year marriage, which lasted from April 2008 to December 2014, due to a prenuptial agreement.

An insider told the mag, "They are in a great place and a real source of support for one another — plus a prime example of what coparents should be."

The exes really do seem to be getting along swimmingly. Cannon, who was dressed as Luigi, attended the "Hero" singer's Halloween party on Oct. 22 and looked like he had a grande old time!

But Carey isn't having such a blast with all of her exes ... On Oct. 27, Carey's rep confirmed in a statement to Entertainment Tonight that she and Packer had split: "Mariah and James had a fight in Greece, and have not seen each other since. The fight was not because of any cheating allegations or excessive spending by Mariah. James is one of the most successful businessmen in the world. They are trying to work it out. Right now, they're not sure if they will stay together. They are discussing it, and plan to release an official statement together about their future."

In the days following that announcement, a reconciliation seems less and less likely, especially since reports claim that Carey refuses to leave the businessman's Los Angeles home and is demanding $50 million.

Since the announcement, many rumors have swirled, including the break up may have resulted because of Carey's extravagant spending, her flirtation with a back up dancer or Packer's anger problem.

It's not good in Carey-Packerville -- but at least the pop star's worked things out with her baby daddy!