If the long press gesture is assigned to other customized function, you can't use it to turn off the phone.
To turn off your phone, you can use the shut down icon on Quick settings panel to open the Power off menu and use the related functions on the menu.
