When the pilot light goes out, the thermocouple turns on the gas supply. The gas supply line is closed when the heat sensor isn't heated by the pilot flame. The pilot light won't stay on if the thermocouple fails.
Let's Get It Fixed!
HomeX virtual experts will assess your issue (for free!) and can resolve simple problems.