The cycling thermostat or the high-limit thermostat may not be the problem but rather the gas valve solenoid coils sitting on top of the gas valve assembly. Disconnect power then verify this condition by bypassing the thermostats. Refer to the image below and locate the thermostats.Note: This is an image of an electric dryer but the thermostat and the thermal cut-off (cut-out) locations are the same.
Disconnect each of the thermostat wires then connect and insulate them properly. Once done, reconnect power and start the dryer. The gas valve solenoid coils are indeed faulty and both need to be replaced if the problem still persists. Click here
for the procedure in replacing the solenoid coils.Gas Valve Solenoid Coils Replacement Procedure
Either or both of the cycling thermostat and the high-limit thermostat are malfunctioning if the dryer continues to heat up with the thermostats bypassed. Disconnect power then reconnect the cycling thermostat wires but keeping the high-limit thermostat bypassed. Reconnect power then start the dryer. The high-limit thermostat is the culprit if the dryer continues to heat up. If not, then the cycling thermostat is the culprit.
Also do the other way; that is reconnecting the high-limit thermostat wires but keeping the cycling thermostat bypassed. The cycling thermostat is the culprit if the dryer continues to heat up. If not, then the high-limit thermostat is the culprit.
Replace the faulty thermostat and it should solve the problem.