Model number would help and without them all you will get is generic information
If it slows down, surges then stops it is most likely a fuel problem .
If it stops like you turned it off then it is most likely electrical .
Simple tests
1) the instant it stops remove the fuel filler cap and listen carefully.
If you hear a sucking sound & problem goes away then you have a tank venting problem
2) If # 1 makes no difference drop a teaspoon of fuel down the carb throat or give it a short shot of carb cleaner
If the engine fires right up then pull the fuel line off the carb & crank the engine
Good fuel supply = faulty carb solenoid
poor fuel supply = blocked fuel line / tank outlet