NEW YORK (Reuters) - Macy's Inc M.N has settled its lawsuit accusing J.C. Penney Co JCP.N of interfering improperly with its exclusive merchandising agreement with Martha Stewart Living Omnimedia Inc.

One of the 68 Macy's Inc stores the company plans to close is shown at the Mission Valley Center mall in San Diego, California, U.S. January 5, 2017. REUTERS/Mike Blake

New York State Supreme Court Justice Jeffrey Oing in Manhattan ordered the case’s dismissal this week, following a joint request from Macy’s and J.C. Penney.

A lawyer for Macy’s confirmed on Thursday that the case has been settled. Terms were not disclosed.

Neither retailer immediately responded to requests for comment.

The settlement ends a five-year-old case rooted in a 2011 agreement in which J.C. Penney was to sell Martha Stewart’s bed, bath and kitchen products in stores then being overhauled by Ron Johnson, J.C. Penney’s chief executive at the time.

Macy’s said this agreement undermined its own exclusive right under a 2006 contract to sell the same kinds of products under the Martha Stewart brand.

In June 2014, Oing ruled against J.C. Penney, following a trial in which Martha Stewart herself had testified.

Two years later, he ordered J.C. Penney to pay Macy’s about $3.5 million of damages. Both companies appealed from that order, but the settlement ends the appeals process.

Macy’s previously settled separate claims against Martha Stewart’s company.

Johnson’s overhaul at J.C. Penney is now widely considered a failure, after it caused a big decline in sales and led to his firing in 2013.

Sequential Brands Group Inc SQBG.O bought Martha Stewart Living Omnimedia in December 2015 for roughly $353 million.

The case is Macy’s et al v. J.C. Penney Co, New York State Supreme Court, New York County, No. 650197/2012.