Stabilisation and extinction mechanisms of flames in cavity flameholder scramjets