The carcass of a 40-foot gray whale that washed up at San Onofre State Beach in California has finally been removed and hauled to a San Diego County landfill.

Crews on Friday finished removing the estimated 60,000-pound carcass of a rotting whale from a Southern California beach, Toronto Sun reports.

The whale was previously seen floating for days at famous surfspot, Lower Trestles, north of downtown San Diego.

The report adds that the $30,000 project that lasted for two days included cutting up the carcass, using an excavator and skimming the top layer of sand to disinfect it from the dead whale's body fluids.

When whales die at sea, they usually sink to the bottom. However, when they float ashore, they literally create a whale of a problem.

According to News Discovery, there are two ways you can dispose a humongous whale carcass: Tow it back out to sea, far enough that it won't wash back onto land; or bury it in the sand.

In an interview with Orange County Register (OCR), State Parks Superintendent Rich Haydon said throwing it back into the ocean was not possible because of the low tides. Burying it also became a challenge because there was not enough sand to dig the deep hole needed to completely bury it.

"As they started to dismember the carcass, they said it was messy but it wasn't as messy as it could have been," Rich Haydon, told the OCR.

When a body of a dead whale decomposes, gas builds up as the animal's viscera and stomach contents decompose. National Geographic notes that whale skin and blubber are tough, which is why their body can handle a lot of pressure. But what causes a whale carcass to explode "is people doing stuff to them, either from bystanders trying to climb on or take a souvenir from the carcass, crews trying to move the carcass, or intentionally degassing them."

Fortunately, the 60,000-pound whale did not explode.

"We were really surprised that there wasn't more seepage coming off of the whale," Haydon said in a separate interview with OCR.

"When we were all there the day before on a site visit, a marine biologist taking blubber samples pierced the skin and it started to off-gas. We think they actually did us a favor by releasing some of that pressure in the whale, because it never popped - it never blew out all the decomposing contents,"he added.

Meanwhile, officers said the smell of the dead whale will linger for a while.