In what cases iOS stops screen recording on its own? I tried making multiple sessions of screen recording on two devices, each recording its own screen: iPhone X and iPhone 5S. The result was that recordings on 5S were in several cases shorter than on X, but I didn't explicitly stop the recording in 5S's Control Center.

Under which conditions could iOS stop the recording at its own initiative / basing implicitly on what I did?

I found only "tapping status bar" that could stop recording (though it asks for user confirmation); is there anything else?
As far as I know, locking the phone (pressing the power button once shortly) will also stop recording.

Just like anything else, it requires enough free space on your iPhone to save the file. However, that doesn’t sound like the problem in your case.

There might be a chance that your iPhone 5S might not fast enough or have enough memory to record as long as your iPhone X.