The end has come for Sedgwick, which announced in November its plans to dissolve at the end of 2017, but if all goes according to plan, the firm won’t head into bankruptcy court. Instead, the U.K.-based law firm Clyde & Co has agreed to hire a number of Sedgwick lawyers and staff members post-dissolution.

Plenty of former high-flying firms have collapsed into bankruptcy, from Thelen and Howrey to Heller Ehrman and Dewey & LeBoeuf. Yet in the half-decade since Dewey’s spectacular demise, other struggling firms, among them Bingham McCutchen, Dickstein Shapiro and WolfBlock, managed to avoid bankruptcy as they wound down, in part by striking deals, like Sedgwick’s, in which large groups of lawyers moved to a single new firm.

Part of the reason for law firms to choose a death of dissolution rather than insolvency stems from the experiences of firms that did go bankrupt, according to lawyers who have worked on law firm insolvencies.

“My advice is stay out of bankruptcy at all costs,” says Blank Rome partner Leslie Corwin. He crafted winddown plans for WolfBlock, which avoided bankruptcy, and for Heller Ehrman, whose bankruptcy case started in 2008 and is still ongoing. (Corwin’s current firm, Blank Rome, absorbed about 100 lawyers from Dickstein Shapiro in February 2016, a move that helped keep the latter firm out of bankruptcy as it dissolved.)

“Nobody who’s been through a law firm bankruptcy has a good rosy feeling about it,” says Latham & Watkins partner Peter Gilhuly, who has worked on a number of law firm dissolutions, including those of Howrey, Thelen, and Brobeck, Phleger & Harrison.

Among other lessons learned: Formal bankruptcy filings by law firms have set off protracted winddown processes that mean lots of administrative fees spent on lawyers, accountants and other professional services. The bankruptcy of San Francisco-based Brobeck offers a sobering example. Brobeck’s case, which began in 2003, stretched until earlier this year. A final report filed in May by Brobeck’s bankruptcy trustee indicates that the case racked up more than $19 million in administrative expenses.

Firm bankruptcies also have tended to give rise to lengthy and costly clawback litigation, in which the bankrupt firms’ estates try to recover fees from lawyers who take ongoing matters with them to a new firm. Clawback cases have, in turn, led some individual partners to declare personal bankruptcy after their firms went bust.

A group composed of hundreds of former Dewey partners, for example, shelled out $71.5 million in exchange for protection from clawback litigation. At least three former Dewey partners who were not part of that settlement group later filed for personal bankruptcy after they were hit with clawback suits; the firm’s bankruptcy trustee took the position in court that Dewey was effectively insolvent, starting in 2009, and that partners’ pay between that point and whenever they left the firm could be recouped.

According to lawyers that have experience with law firm dissolution, avoiding a bankruptcy proceeding can make it easier to collect on outstanding bills from clients, and it helps insulate the fate of a dissolving firm from outside parties, keeping the winding-down process in control of the firm’s management and its legal and financial advisers.

What’s different in some of the recent cases, these lawyers add, is that the dissolving firms have managed to successfully line up deals that provided a landing spot for many of their lawyers, while crafting plans to satisfy the firm’s creditors and landlords enough to dissuade them from forcing an involuntary bankruptcy.

Keeping bankruptcy at bay typically requires the crafting of a careful dissolution plan, says Corwin. He suggests that a struggling firm hire a legal team that can help reach deals with creditors outside of court. “You want to get someone like me to write up a plan of dissolution that keeps you out of bankruptcy,” says Corwin. “If it’s a plan that’s well run and well thought out, it’s going to cost partners a lot less than a bankruptcy situation will.”

Aside from benefiting partners, who often already stand to lose some or all of their capital contributions in their firm if it goes bust, a dissolution plan offers a possible upside for creditors, according to Gilhuly. Creditors in insolvency situations have grown more sophisticated in recent years, he says, and they can often anticipate how much of their investment they’ll likely recover from a defunct business in a bankruptcy proceeding. If they can reach a similar outcome while staying out of court, all the better.

“There’s a lot more sophistication to avoid those kinds of costs,” says Gilhuly. “The trend in the law firm insolvency is mirroring or tracking the trend in the non-law firm insolvency world.”

Also in the mix is a possible change in legal precedent that could affect the appeal of clawback litigation for law firm bankruptcy trustees. A California appeals court ruling from 1984, Jewel v. Boxer, has long held significant sway over those types of lawsuits based on what’s known as the “unfinished business” doctrine. The doctrine, as applied in Jewel, holds that a defunct law firm’s accounts receivable—bills for ongoing matters—are an asset of the defunct firm.

The ruling effectively gave a green light for bankruptcy trustees to try to claw back fees from matters that lawyers started while still at a now-insolvent firm, even if the lawyers brought those matters to a new firm and completed most of the work there. The California Supreme Court, however, is currently reviewing that precedent in connection with appeals in the ongoing Howrey and Heller Ehrman bankruptcies.

It remains to be seen how the court will rule; the court heard arguments in the case on Dec. 7, but it has yet to issue a decision.

If the unfinished business doctrine disappears as a result of the eventual ruling, that might make a law firm’s bankruptcy even less fruitful for creditors, and it would give a bankruptcy trustee fewer assets to recover in a clawback case, says Gilhuly. That, in turn, could increase the chances that struggling law firms in the future can avoid bankruptcy court.

“If the ongoing matters are not the property of the law firms,” Gilhuly says, “that takes away one huge incentive to file.”