When the mower idles, it still needs to pull in enough air to mix with the fuel, then needs to vent those burnt-up gases. If the air gets blocked on either end of the engine, the mower idles roughly and usually eventually stalls out. Dirty air filters need regular washing, generally after every 10 to 15 hours, and replacing every season. Mufflers in most lawn mowers contain a spark arrestor screen that keeps any ignited gasses from escaping. This screen needs a thorough scrubbing after every 60 hours.
After you let go of the accelerator, a lever closes the main vents on the carburetor. However, a small jet remains open to let fuel in. If the fuel can't reach the carburetor through this vent, the mower stalls out. The fuel can get stopped at many different points in the fuel system. The most common points are the fuel tank, the fuel filter and the fuel hoses. These parts need regular maintenance and cleaning. Replace the fuel filter every season, and the fuel hoses every other season.
After cleaning the air systems and checking the fuel systems, the engine still may idle rough and stall out. If this continues to occur, perform a carburetor adjustment to the idle and low-speed settings on their respective carburetor screws. Opening these two screws up just a little allows more fuel to flow into the carburetor at these speeds and improves idling. A carburetor adjustment is a temporary fix as the carburetor is most likely in need of a cleaning.
If the idle jet inside the carburetor gets clogged or stuck closed, the carburetor needs to be disassembled and cleaned. After disassembling the carburetor, soak all of the parts in a carburetor cleaner bath overnight to dissolve any built-up material. Replace all of the gaskets in the mixing, metering and pump sections before rebuilding the carburetor. It also helps to install a carb kit to the front end of the carburetor, which aids in drawing fuel into the carburetor.