Dieseling is so-named because it is similar in appearance to how diesel engines operate, by firing without a spark. However the ignition source in a diesel is the compression of the gas in the cylinder, while in the dieseling phenomenon the compression ratio is not sufficient to ignite the fuel and it is a hot spot inside the cylinder that starts combustion.
An automobile engine that is dieseling will typically sputter then gradually stop rather than continue running as if the engine was not switched off at all — the latter would usually indicate an electrical fault.
Dieseling is not nearly as common as it once was because it most commonly occurs in carburetted engines. The vast majority of American, European, and Japanese vehicles manufactured after 1990 are fuel-injected-- the injectors and high-pressure fuel pump immediately cease supplying fuel to the cylinders when the ignition is switched off. If the injector is damaged or malfunctioning, a small amount of fuel can enter the chamber and be ignited, causing a sputter or two after the engine is switched off.
Ironically, dieseling (in the sense of engine run-on, and disregarding combustible gaseous mixtures via the air intake) cannot occur in diesel engines because they are controlled entirely by the rate fuel is delivered to the cylinders. The only way to shut them down is to cease fuel delivery. Whether electrically or mechanically driven, the fuel pumps and injectors are switched off to stop the engine.
Some carburetted engines have fuel pumps, but they are often low-pressure. They are typically designed only to overcome a loss of suction in the fuel line near the engine due to fuel evaporation in hot weather, to supply sufficient fuel to maintain stoichiometric combustion under heavy load with wide-open throttle, or a combination of the two. Fuel demand is low at idle and there is more than enough manifold vacuum to draw sufficient fuel for combustion even if the fuel pump is switched off.
Gasoline engines that are much smaller than the typical automotive engine are usually carburetted for economic and engineering reasons. Dieseling can occur in such engines. These engines include those installed in mopeds, scooters, small motorcycles, ATVs, and most lawn-and-garden power tools.
For those engines that have sharp metallic edges, it has been noted that poorly milled heads and blocks can contribute to this problem, so having the rough spots smoothed may help.
For those engines that run too hot or too lean, verify that all mechanisms in place to cool the engine properly function as they should. Replace the thermostat if necessary. Clean the radiator. Verify that all auxiliary fans engage at their proper temperatures, and ensure that the thermostatic sensors on belt driven fans engage as necessary.
In the case that there is too much angular momentum, lower the idle speed if possible.