In early 2013, Tesla Motors CEO Elon Musk was close to settling a deal that would have had Google buy Tesla outright for $6 billion, with $5 billion additional for future factory expansions.

On May 8, 2013 Tesla posted its first ever quarterly profit, nearly surprising everyone due in part to a higher demand for the Model S than expected. Just weeks prior, Tesla had been on the verge of bankruptcy.

The issue – according to a write-up by Bloomberg reporting on a book due May 19, “Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future” – was in early 2013 Tesla was turning preorders of vehicles into sales.

According to Tesla spokesman Ricardo Reyes and Google spokeswoman Rachel Whetstone, Musk was negotiating a deal to sell the company to his friend and Google CEO, Larry Page.

SEE ALSO: Lawmakers Open Exception For Four Tesla Stores In Maryland

While Tesla had spent numerous years designing and building the Model S, the vehicle was lacking a few key components when it went on sale in June of 2012. It didn’t offer parking sensors and radar assisted cruise control like BMW or Mercedes-Benz, and glitches with the 2012 models door handle irritated some.

Ali Javidan, a former Tesla engineer said that all of this was largely due in part to lack of resources.

“It was either hire a team of 50 people right away to make one of these things happen, or implement things as best and as fast as you could,” said Javidan.

By the end of 2012, sales were beginning to slow, and many were left wondering if Tesla would be able to eradicate the remaining bugs. With the company in a downward spiral, shares plummeting, and sales targets missed, Musk called staff in from every department and ordered them to call those who reserved Teslas in order to finalize deals.

“If we don’t deliver these cars, we are #%$^,” Musk said, according to an individual at the meeting. “So I don’t care what job you were doing. Your new job is delivering cars.”

Along with these last minute sales attempts, Musk was also firing senior executives and promoting eager junior employees. As well, he went on to hire former Daimler executive Jerome Guillen to try and alleviate Tesla’s repair service, getting glitchy cars back on the street in a more timely and efficient fashion.

In March of 2013 Musk had reached out to Page, proposing that Google buy Tesla for $6 billion, but wanted the guarantee that it would not break up or shut down Tesla until its third generation electric car had reached the mainstream market. Also requesting that Page let him run a Google ran Tesla for eight years, or it began creating the previously mentioned car. Page agreed to the terms set by Musk.

With these negotiations nearly concluded, Tesla’s last minute sales calls began to work and it started selling thousands of cars, posting an $11 million quarterly profit on $562 million in revenue.

Shares had doubled, and its $465 million loan to the Department of Energy was paid off. Musk broke off negotiations with Google, no longer needing its aid.