The manufacturer on Wednesday posted the biggest quarterly loss in its history as costs piled up and it took a nearly $5 billion charge to compensate airlines affected by the worldwide grounding of the 737 Max, now in its fifth month. Boeing warned its costs from the grounding could climb if it wears on longer than expected.

The 737 Max has been grounded since mid-March following two fatal crashes. Investigators implicated a piece of new flight-control software in both air disasters that repeatedly pushed the nose of the planes downward. A total of 346 people were killed in the two crashes. Boeing has developed a software fix and aims to submit that and other requirements to get the planes flying again to the Federal Aviation Administration in September, CEO Dennis Muilenburg said on an earnings call.

Boeing expects its troubled 737 Max jets to return to the skies by early in the fourth quarter but its CEO warned investors on Wednesday that it could further cut or suspend production of its bestselling planes altogether if delays get worse.

Boeing in April cut production of the planes by nearly 20% to 42 a month in the wake of the second crash in Ethiopia a month earlier. Muilenburg told analysts that it expects to maintain that rate and ramp up production to 57 a month in 2020, if as it anticipates, the planes return to service early in the fourth quarter. But if the return date is further delayed, Boeing could cut production more.

"Should our estimate of the anticipated return to service change, we might need to consider possible further rate reductions or other options including a temporary shutdown of the Max production," Muilenburg said. The CEO later added that "a temporary shutdown of production line could be more efficient than a sustained lower production rate" because it could reduce storage requirements.

Shares of Boeing extended their losses after Muilenburg's remarks, trading 3% lower and shaving nearly 80 points off the Dow Jones Industrial Average in afternoon trading.

The grounding has vexed Boeing's airline customers that have canceled thousands of flights during a busy summer travel season. Carriers including United, Southwest and American have removed the planes from their schedules until early November, leading to thousands of more flight cancellations. Further delays could crimp their operations during the Thanksgiving and Christmas holiday travel period.

Boeing had delivered about 400 737 Max planes to airlines at the time the aircraft was grounded worldwide in March. After the second crash, Boeing said it would suspend deliveries to carriers and has been storing the jets in Texas and at its facilities in Washington state, including in an employee parking lot.

Companies that make parts for the 737 Max were trading lower. Spirit AeroSystems Holdings, which makes fuselages for the 737 Max was off 2% and materials providers Hexcel and Allegheny Technologies, were down 0.4% and 2.3%, respectively.

Muilenburg warned currently reduced 737 Max production at 42 a month will delay deliveries to airlines in the future once production resumes.

Regulators have not said when they expect to allow the planes to fly again.

Treasury Secretary Steven Mnuchin told CNBC's "Squawk Box" on Wednesday that the U.S. wants to "absolutely make sure that before the 737 Max flies that it's safe."

"I think there's no question Boeing has the financial capacity to fix this but I think we need to make sure they're fixed and we need to figure out how they compete against Airbus," he said, referring to Boeing's European rival, which is wrapped up in a trade dispute over U.S. accusations of illegal subsidies.

Boeing said the financial guidance it issued earlier this year doesn't reflect the Max impacts and "due to the uncertainty of the timing and conditions surrounding return to service of the 737 Max fleet" it would issue new guidance at a later date.

Boeing's $4.9 billion charge and the $1.7 billion increase in costs related to the 737 Max grounding does not include sums that it may have to pay in dozens of lawsuits related to the crashes. A Lion Air flight in Indonesia in October killed all 189 aboard, while an Ethiopian Airlines 737 Max that crashed shortly after takeoff in March killed 157 people. It also doesn't include the $100 million that Boeing said it would set aside for victims' relatives and their communities.

Aside from the Max woes, Boeing said the first flight of its revamped double-aisle 777x jetliners would take place in 2020 instead of this year due to issues with the planes' General Electric engines. Boeing warned that "there is significant risk" to its plans to first deliver these planes to airlines next year because of the ongoing problems.