An iPhone that keeps restarting is a serious but uncommon problem. Here are a few ways to try and fix the issue.
You can restart the Touch Bar on a Mac when it occasionally freezes or stops without restarting the entire laptop.