App to turn off cell phone

You can use some third party apps to achieve what you want to. But, if you want to make something like that in Koduar/AI2. Here are some suggestions.

Try using shell component with some commands.

Power off
reboot -p or reboot --poweroff ( the same command )

Reboot
reboot

Note : this doesn’t require root access as this binary is world executable ( non-root users can execute this ). I haven’t tested this myself in newer android versions. Maybe this could’ve been changed for security reasons.

These below commands will work as well. But, I don’t know if they’ll require root access or turn off them properly / forcefully.

halt, poweroff

By sys-rq ( root/su )
( System Request ) works by echoing letter commands to it ( > ). This is a kernel temp file.
echo o > /proc/sysrq-trigger for Shutdown
echo b > /proc/sysrq-trigger for Reboot