If you can’t turn off iPhone or if the problem continues you may need to reset your iPhone.
A reset should be done only if turning iPhone off and on doesn’t resolve the problem. Be sure to have a current backup.
Reset iPhone: Hold down the On⁄Off button and the Home button at the same time for at least 10 seconds, until the Apple logo appears.