Stale gasoline lacks the volatility needed for proper combustion and could cause knocking or stalling. Contaminates in the fuel, such as water, can create the same symptoms or damage the engine. Drain the fuel system and add fresh gas if contamination is suspected or if the fuel has been in storage for a month or longer. Low engine oil levels can make the motor overheat, knock and stall. Ensure the proper oil level is maintained at all times.
Pre-ignition is called "spark knock" because of the noise the condition produces. One reason for spark knock in small engines is improper ignition system function. You can check this function with a spark tester that is inserted into the spark plug wire and grounded to the engine block. Weak or erratic sparks displayed when the engine is cranked may indicate a bad plug wire or ignition coil. Replace the spark plug if the electrodes appear worn or fouled by oil or gasoline.
The flywheel of a small engine is typically held in position partially by a key that rests in a groove on the crankshaft. The key can wear over time or become compromised if the mower blade makes harsh contact with a heavy or fixed object. The flywheel triggers ignition operation when a certain portion of the flywheel passes the ignition coil assembly. Replace the flywheel key if it allows any looseness or appears damaged in any way.
Carbon deposits form on piston and valve surfaces over time. Heavy deposits on the top of the piston can raise the compression ratio of the engine enough to cause spark knock. Light deposits result in the same symptoms by retaining heat sufficient to ignite the combustion mixture. You have to remove the engine cylinder head and scour or scrape away the deposits manually. Heavy, rapid knocking may indicate failed engine components. Small engine repair can be complicated and might best be left to professionals.