Tesla chief executive officer Elon Musk said the electric car company had a near-death experience earlier this year that had him working nonstop, taking a “painful” toll on his well-being.

“Tesla really faced a severe threat of death due to the Model 3 production ramp,” Musk said during an interview with Axios on HBO that aired Sunday night. “Essentially, the company was bleeding money like crazy and if we didn’t solve these problems in a very short period of time, we would die. And it was extremely difficult to solve them.”

By June, Tesla hit a key production milestone, with 5,000 Model 3 sedans manufactured in a week. In October, Tesla posted its first profitable quarter in two years.

But Musk said he wouldn’t recommend anyone work as much as he does — which at one point meant seven days a week, and even sleeping in the factory.

“It hurts my brain and my heart,” he said.

Musk blamed working long hours and being tired for his “bad manners” on a call with investors earlier this year, in which he dismissed some analysts’ questions as “boring.” His behavior on Twitter also became even more erratic, with tweets that bordered on the bizarre and had an impact on the company’s stock price.

In August, Musk sent an impromptu tweet claiming he had secured funding to take Tesla private at $420 a share. That prompted an investigation and subsequent $40 million fine from the Securities and Exchange Commission, who charged him with fraud in September.

Musk also runs SpaceX, The Boring Company and serves as CEO of Neuralink, a company developing brain-machine interfaces.

As if that weren't enough, there is one more challenge that might be in his future, he said: A move to Mars. SpaceX is currently working on Starship, formerly known as the Big Falcon Rocket, which will be used to one day colonize Mars. Musk put his odds of a move at about “70 percent,” but said there’s a likelihood he’d die there.

“Your probability of dying on Mars is much higher than on Earth,” he said. You are “going in a little can through deep space. You might land successfully, but once you land successfully, you’ll be working nonstop to build the base, so not much time for leisure.”

A fully sustainable civilization on Mars could be a possibility in the next 40 to 100 years, Musk has previously said. Tickets to the red planet would cost about at least $200,000, he estimated.

With rapid advancements in artificial intelligence, Musk also said people need to take seriously the potential that artificial intelligence has to destroy humanity. Musk has long said the solution will be for humans to merge with machines, with a tiny chip implanted into their skulls.

“How do we ensure that the future constitutes the sum of the will of humanity?” he asked. “And so, if we have billions of people with high bandwidth link to the AI extension of themselves, it would actually make everyone hyper-smart.”

Musk said he believes the symbiosis between man and machine could take place within a decade — and that humanity is already on the path of merging the two.

“You kind of have this already in a weird way,” he said. “You have a digital tertiary layer in the form of your phone, your computers, your watch. You basically have these computing devices that form a tertiary layer on your cognition already."