Federal officials came so close to shutting down Metro in the spring of 2016 that the discussions reached the White House, where officials were concerned about potential security impacts for the region, according to individuals with knowledge of the matter.

Nearly two months after Metro General Manager Paul J. Wiedefeld ordered the emergency day-long shutdown of the system for extensive cable repairs, an exploding insulator sent a ball of sparks raining onto a train platform at rush hour, paralyzing service on three lines. Officials, including U.S. Transportation Secretary Anthony Foxx, huddled late into the evening at the Transportation Department to sort out their response.

The next day, May 6, 2016, Rhonda M. Carter — Transportation’s deputy chief of staff — fired off an email to her former colleague, Peter Rogoff, who had taken a job as head of the Seattle-area transit agency Sound Transit.

“[I]f it helps to affirm your decision to move far, far away, I’m sure you are more than glad that you were not anywhere near the makeshift war room I was in last night until 1 AM deciding on next steps regarding the ongoing dumpster fire that is WMATA in its current state,” wrote Carter, now chief of staff for Sound Transit, according to an email obtained this week through a public records request.

Carter declined to comment on her remarks, though her characterization is not in dispute among top officials. “I’d say that’s probably accurate back in those days,” Metro Board Chairman Jack Evans said.

As the Federal Transit Administration prepares to hand safety oversight for Metro to the new Metrorail Safety Commission, documents obtained this spring illustrate how dire the situation had become when federal officials took over in October 2015. The FTA assumed responsibility from the failed Tri-State Oversight Committee. Federal officials had the authority to shut down all or parts of the system, and on several occasions nearly did.

“I almost shut them down,” Foxx said last week.

At the time, federal officials were holding daily meetings on Metro, and one that stretched late into the night came at a turning point — an exploding insulator triggered a rush-hour meltdown just as Wiedefeld was set to release SafeTrack, his long-anticipated plan to rescue the system.

“The equivalent of roughly 10 percent of the FTA was somehow focused on this one system,” Foxx said, noting that the Metro oversight staff of around 30 included individuals borrowed from other parts of the Transportation Department, including the Federal Railroad Administration and Federal Aviation Administration.

“We had to ultimately put essentially a strike force together . . . to do some of the state safety oversight that the failed safety oversight group had failed to do,” Foxx said. “So we literally had people going out to inspect the inspectors.”

But even SafeTrack, a rehabilitation program that compacted three years of repair work into one, was not viewed as a panacea. The FTA expressed its doubts about the program from the start, according to briefing materials obtained by The Washington Post. “FTA faces challenges . . . in getting information from WMATA in advance of decisions,” said one report, “(for example, the SafeTrack plan was not shared in advance, in spite of repeated requests).”

The communication lapse culminated in the FTA ordering Metro to reshuffle its SafeTrack schedule to hit what federal officials deemed high-priority areas first. They even complained that Metro did not consult them on its fix for the exploding insulator.

“WMATA also routinely announces safety measures (like replacing all porcelain insulators in tunnel stations) without opportunity for FTA input,” the FTA said. (Metro pointed last week to a news release that said Wiedefeld had consulted with the FTA and the Transportation Department the day of the incident.)

But a week after that embarrassing episode, still not confident in the state of the system, a delegation from the FTA was summoned to the White House, where National Security Council staff peppered them with questions, from how likely a shutdown scenario was to how long it could last and how the situation could affect the movement of elected leaders, said an individual with direct knowledge of the matter, who spoke on the condition of anonymity because of the private nature of the discussions.

The FTA even developed a contingency plan, including scenarios for station, line and system closures and what the criteria would be for Metro to fully reopen. The document, which has not been publicly released, was effectively a Metro shutdown plan, the individual said.

“Very close. Very close,” Foxx said when asked how close he was to shuttering the system. “Essentially the safety incidents had increased to the point where not only were they happening but I was becoming less and less confident — I think we were becoming less and less confident — that they had a good handle on how to fix them.”

Foxx also acknowledged the existence of a contingency plan.

“What I wanted was essentially a document that would outline the steps to be taken under such an occurrence, not only for my immediate purposes but for future purposes,” he said.

A rush-hour derailment in July 2016 exposed a raft of falsification and neglect in Metro’s track inspection department and led to further contemplation on the part of federal officials, who ultimately decided against shutting down the system. The derailment did, however, lead to further adjustments to SafeTrack.

“I was fully prepared to shut the system down, and as we were working toward that [Metro] reached its own conclusion independently that a shutdown was necessary and they did so,” Foxx said. “And so the stand-down that general manager Wiedefeld executed on coupled with the SafeTrack plan ultimately satisfied us that they were taking steps to right the ship.”

Riders know what happened next. A year of painful service disruptions with segments of rail lines closed for weeks at a time, driving ridership below 650,000 daily trips. The ridership losses ate into Metro’s revenue and forced the agency last summer to implement fare hikes and service cuts — along with ending late-night service indefinitely. The region united around a plan to provide $500 million in annual dedicated funding to the system, though a full-scale governance overhaul championed by reformists was not implemented.

“I think at the end of the day the system is better today than it was back then and I think the region is now thinking more holistically about . . . how to put the system on a more stable financial footing and ensure it has the components to be successful,” Foxx said. “The darkest days are behind us hopefully, but you know . . . ”

Evans, thinking of Carter’s earlier characterization, reflected on Metro’s position succinctly.

“We’re not the dumpster fire today,” he said. “We’re far superior to that.”