Your laptop is sitting on the couch next to you while you’re playing video games, and suddenly it starts smoking. What should you do?

When their Dell laptop exploded into flames earlier this month, two California teens managed to avoid a house fire or a serious injury by blowing out the flames and moving the device outside. Then they posted a video of the incident, reportedly captured by a home security camera.

Fire safety officials say that the teens mostly did the right things in responding to the fire—but were also lucky to escape uninjured.

Lithium-ion battery fires have been in the news a lot in the past year, thanks to exploding Samsung Galaxy Note7 smartphones, a recall of HP laptops, and a series of hoverboard fires. However, such incidents are still rare. “There are millions and millions of lithium-ion batteries in use in cellphones and laptops every day,” says John Drengenberg, the Consumer Safety Director of Underwriters Laboratories. "And the vast majority of them don't have any problems at all."

Of course, that's only reassuring until it happens to you. Here's what you need to know about why laptop batteries can explode, and the best way to handle the situation.

Why Batteries Explode

To put it simply, blame thermal runaway. The major parts of a li-ion battery, the cathode and anode, are separated by a permeable membrane, and the battery works by undergoing a controlled chemical reaction. If the membrane is compromised, the chemistry can go into overdrive and dump all the battery's energy at once. Temperatures can climb past 1,000° F in a few seconds, leading to a fire or explosion.

Unlike the smaller, single-cell battery in a cell phone, a laptop has multiple cells that can each be damaged by the heat from an adjacent cell. That's why the computer in the video kept re-igniting like a set of trick birthday candles. “It’s a chain reaction,” Drengenberg says.

According to Dell, the battery that caught fire hadn't been supplied by the company. “Evidence taken directly from the laptop proves, definitively, that the battery was not manufactured by Dell and was not an authentic Dell battery,” public relations vice president Dave Farmer tells Consumer Reports. According to Farmer, someone had installed a third-party battery that may have lacked the safety features that were built into the original battery.

What to Do About a Battery Fire

1. Call the fire department. First, treat a burning laptop like a real fire. Because that's what it is, according to James Long, director of public information with the New York City Fire Department.

Call 911, and then evacuate people and pets from the home. In addition to the fire danger, the plastics and chemicals inside can give off toxic fumes, Drengenberg says.

Unfortunately, many people are reluctant to call the fire department for anything less than the Towering Inferno—and that's a problem for firefighters.

“We get that all the time,” Michael Zezze, assistant chief of the Chappaqua, N.Y., fire department, says. His department handled one of the first fires caused by li-ion batteries in a hoverboard. “There’s nothing to be embarrassed about. We’d rather show up and find out it was nothing than to have to respond to a fully involved structure fire because someone was reluctant to call.”

If the laptop is just extremely hot or starting to smolder, there are other measures you can take.

2. Unplug the laptop. If you can do so safely, unplugging the laptop is a good first step, according to Long, because it isolates the device from the wall current and keeps additional power from being delivered to the battery. However, as you can see in the California video, unplugging the computer won’t prevent a subsequent fire or explosion if the battery is already in thermal runaway.

3. Remove nearby combustibles. The teens got this right. They removed the laptop from the couch, which could have easily ignited and set the whole room ablaze. Long suggests moving papers, pillows, and other combustibles away from the computer—again, if it can be done safely.

4. Air it out. The next step would be to move the device outside, if the fire is in its early stages. That allows the fumes to vent and prevents the laptop from setting the house or its contents on fire.

“But you want to be mindful of the fact that a fire can double in size within 20 to 30 seconds,” says Long. “You don’t want to put yourself in any danger.”

5. Water it down. It may seem counter-intuitive, but water works in a case like this. “What we’re attempting to do is cool down the device,” Long says. “If you can, get it into a sink.”

Zezze also suggests using a conventional ABC dry chemical fire extinguisher of the type you might find in your kitchen. Since the extinguisher can spray effectively from across a large room, you can stay at least 10 feet from the device. “Keep a safe distance,” he says. “There’s no reason to be right on top of it. You could be dealing with burning shrapnel.”

6. Continue to monitor the device.
Even after the device seems to be out, there may be damage to a cell that can cause the fire to re-ignite. “These fires tend to be unpredictable,” Zezze explains. “They can flare back up after three, five, or ten minutes.”

In this case shown in the video, the cells seemed to ignite at regular intervals, a few minutes apart. But that's not always the way battery fires develop.

Dan Gorham, project manager with the Fire Safety Research Foundation, a nonprofit group, recalled a training exercise when large li-ion batteries from a burning electric car re-kindled a full 24 hours after the fire department sensors suggested that the fire had been extinguished.

“You had a battery that was incompletely discharged,” Gorham says. “And that stranded energy, that’s a hazard."

How to Use a Fire Extinguisher

A fire extinguisher might seem like a simple device, but you would be surprised how many people don't know how to use one. On the "Consumer 101" TV show, host Jack Rico explains what you need to know.