How do you exit guided access when it freezes?
A triple-press of the side button should prompt to exit Guided Access using a passcode.

A double-press of the side button should use Face ID to authenticate exiting Guided Access.

Force restart iPhone:

Press and quickly release the volume up button, press and quickly release the volume down button, then press and hold the side button. When the Apple logo appears, release the button.