After years of struggling to adapt to the digital era, RadioShack on Thursday filed for Chapter 11 bankruptcy.

Under the agreement, hedge fund Standard General will purchase up to 2,400 of RadioShack’s stores.  Of the stores purchased by Standard General, wireless carrier Sprint will establish a “store within a store” model in up to 1,750 of them.  The company plans to close the rest of the stores that it owns, which currently number 4,000.

The company said that its stores in Mexico and Asia are not included in the bankruptcy filing.

“These steps are the culmination of a thorough process intended to drive maximum value for our stakeholders,” Joe Magnacca, RadioShack’s chief executive officer, said in a statement.

The writing had been on the wall for the storied electronics chain:  It hadn’t turned a quarterly profit since 2011. It had tried to close 1,100 stores last year, only to be blocked by creditors. This week brought the clearest sign yet of its struggles: With RadioShack’s stock trading for mere pennies, the New York Stock Exchange delisted it.

RadioShack had tried one thing after another to turn its struggling business around.  In the early 2000’s, as cellphones were on their way to becoming ubiquitous, it focused its strategy on selling the devices.  When the market for them become saturated, RadioShack tried a host of other things, including store redesigns and a renewed marketing push around its “do-it-yourself” roots.  But none of those efforts could help sufficiently stanch the profit losses.

Standard General had given RadioShack a $120 million financing lifeline last year.