To shut down your phone, you can press and hold the side button to activate your phone's assistant, then say 'Power off' into the microphone to bring up the Power off menu.
Alternatively, you can change the side button's function so that it works solely to power off your phone. On a Samsung phone, go to Settings > Advanced features > Side button, then select 'Power off menu' in the 'Press and hold' category. On a Pixel, go to Settings > System > Gestures, then tap 'Press and hold power button'. From here, select 'Power menu'.