The most likely reasons why your iPhone won't turn off are: It's frozen due to software problems. The Sleep/Wake button is broken. The screen is broken and isn't responding to taps.
iPhone With Face ID
Hold down the Side button and either one of the Volume buttons for a few seconds. This will bring up a screen with a slider at the top. Drag the slider over until your device turns off.
With the AssistiveTouch® feature, you can restart your phone—and possibly resolve the problem—without using the Power button. Here's how: Go to Settings > Accessibility > Touch. Tap the AssistiveTouch button, then tap the switch to turn it on.
The iPhone case is causing interference with the power button. A significant amount of dirt has accumulated around the button. The device suffered a fall on its side, which resulted in physical damage. A software glitch that's causing the power button to be unresponsive.
So what cause the "slide to unlock" and "slide to power off" doesn't work on iPhone? Well, either software problem or the hardware issue is the reason. For hardware problems, there could be the glitch of touch screen sensitivity, short circuit, or the broken mainboard or screen.
(1) Try and Force Restart your iPhone EXACTLY as shown below and see whether that resolves the issue: Press and quickly release Volume UP button. Press and quickly release Volume DOWN button. Press and Hold the SIDE button until an Apple logo appears and then release the Side button (Can take up to 20 seconds.
Press the Side button to turn on the phone. Press the Side button to turn on the screen lock. Press the Side button to turn on Siri. Slide the Silent mode key right or left to turn silent mode on or off.