Your problem could be electrical or fuel related
SO to cut down the possibilities arm yourself with an inline spark tester like the Oregon 42-087 and a spray can of carb cleaner.
Fit the tester & go mow, while the engine is generating it will glow red.
If it stops glowing red before the engine cuts out you have an electrical problem, most likely the magneto coil
If it glows red, then starts to flash as the engine slows down to a stop you have a fuel problem.
Quickly squirt a SMALL SPRAY ( less than 1 second ) of carb cleaner & crank the engine.
If it starts up then that confirms a fuel problem
You can the start to isolate the problem as previously mentioned by loosening the fuel cap.
If you hear a sucking or the mower starts right up again, new fuel cap time
If not then you are looking at a blockage somewhere between the fuel outlet in the tank and the carb float bowl.