Hello lievenhermse, have you by chance tried another good working battery in your phone to eliminate the chances of it being an issue related to the battery? If you have access to a good working battery I would try to see if the good battery will solve the issue. The current battery may have starting failing which could cause the phone to possibly freeze up and then turn off due to the components on the motherboard not receiving enough voltage to the point it powers off the phone. There are other possible causes. I would suggest trying another battery or buying a new battery to see if that will solve the issue.
You can sometimes tell just by looking at the battery if it may be damaged. One way to tell is if the battery appears to be a bit swollen in the center, it may still function but a swelling battery is a good sign it's in its last stages of life and will soon likely need replaced.
You can also tell by laying the battery flat on a smooth hard surface and try to spin it. If it spins easily like a top then the battery is swollen and should be replaced.
Does the phone get hot when this issue tends to happen?
If the phone freezing up and shutting off has happened often in the past but the phone would still power on after it had been left untouched for awhile makes me wonder if the phone overheats under heavy use then freezes and shuts off. Leaving it sit for awhile and then it turning back on may have allowed enough time for the device to cool down and power on and function properly until it overheats again. If this sounds like a process your phone has went through and now no longer powers on even after trying with another battery then it is likely an issue with the motherboard. Over heating could have possibly fried the processor or other components like a power management IC.
I believe if it was a software related issue that the phone would just freeze up and hang but stay powered on, and not turn itself off. It freezing and powering off and not power back on is why I am thinking it may be a hardware issue like a faulty battery or an issue on the motherboard.