If your iPhone won't turn off the usual way, you can force restart it with a button combination specific to your iPhone model ...
Next up is the action button, up on the left-hand side as you look at the iPhone, which has replaced the old ring / silent ...
DFU mode can help you recover your iPhone or iPad using a computer.