Hold down the power button (top right) for 5 seconds. The screen will show "Slide to power off".
If this does not work, continue holding it for 10 seconds, and it will shut off.
To turn it back on again, push the power button.
If the iPhone is unresponsive to holding the power button, press and hold both physical buttons (power button and round "home" button) for a few seconds and the phone will immediately reboot.