LOS ANGELES — A fire that raged overnight on the underside of an old wooden wharf was finally quelled Tuesday, but not before all container terminals at the Port of Los Angeles and several in adjacent Long Beach harbor were shut down because of worries about unhealthy smoke.

Concern about the plume from burning creosote-preserved timber in the pre-World War II wharf also triggered a precautionary evacuation of a port-area elementary school and advice to residents to stay indoors.

The eight Port of Los Angeles terminals were to remain closed until the 6 p.m. night shift, port spokesman Phillip Sanfield said. He estimated a few thousand employees, mostly longshore workers, were sent home. At the neighboring Port of Long Beach, three of six cargo terminals were shut down.

Los Angeles firefighters use foam to control a dock fire at the Port of Los Angeles in the Wilmington section of Los Angeles on Tuesday, Sept. 23, 2014. Image: Nick Ut/Associated Press

A welding accident Monday evening ignited the 800-foot-long wharf, which has a warehouse running most of its length.

Fireboats spraying water and foam, scuba divers, and firefighters ashore contained the bulk of the fire after about 2 and a half hours, but it continued to smolder and officials said it might be Tuesday evening before it was fully extinguished.

"This is a very, very difficult fire to fight," said Los Angeles Fire Department Chief Ralph Terrazas.

The twin ports of Los Angeles and Long Beach handle 40% of America's import trade.

The economic impact of the fire was not immediately known and will depend on what kind of cargo was being held on the docks. Sanfield said he expected the dollar loss would be minimal because dockworkers have been able in the past to catch up when weather or labor unrest shut the port for a day.

The Port of Los Angeles handles an average of about $780 million of cargo each day, and the consequences of delays in moving that much product will reverberate down the supply chain — from truckers who wouldn't get paid for the day to exporters and retailers whose products won't show up right on time.

Outside the port, the fire's main impact came in the form of precautions for potential health impacts from the smoke.

A plume of smoke rises from a dock fire at the Port of Los Angeles in the Wilmington section of Los Angeles on Tuesday, Sept 23, 2014.

Fire and police officials advised residents in the Wilmington and San Pedro neighborhoods of Los Angeles as well as the city of Long Beach to remain indoors and keep windows closed.

Per @SouthCoastAQMD Smoke Advisory from #WharfFire PortofLA has caused poor air quality that affects Wilmington and surrounding areas. — LACoFD (@LACo_FD) September 23, 2014

The South Coast Air Quality Management District also issued a smoke advisory Tuesday, asking residents who could see or smell smoke to avoid going outside. Masks won't adequately help, the district stated, noting that a sea breeze from the morning may have also swept smoke further on shore. The Long Beach Department of Health and Human Services echoed the district's warning.

Wharf fire at #portofla. In area with smoke? Avoid any vigorous outdoor or indoor exertion. — Long Beach Health (@LongBeachDHHS) September 23, 2014

About 700 students and 30 faculty members at De La Torre Elementary School were taken by bus to Olguin High School, on the campus of San Pedro High School, said Monica Carazo of the Los Angeles Unified School District.

She said the move came after fire officials grew concerned when shifting winds sent smoke toward the school.

According to KNX, some angry parents pulled their kids from De La Torre for the day. Parents also expressed frustration over how long it took to evacuate the campus.

Angry parents pull kids out of George De La Torre Jr. school in path of smoke from L-A port wharf fire @KNX1070 pic.twitter.com/Bn2tXJGoce — Ron Kilgore (@ronkil) September 23, 2014

Other schools remained open with all outdoor activities suspended. One parochial school stayed closed for the day.

Terrazas said, however, that hazardous air quality levels were reported only in the immediate proximity of the fire.

The amount of smoke greatly diminished by midday as firefighters continued to spray water and fire-fighting foam onto hotspots.

Additional reporting by Mashable