Your device will need to be rooted to do that.
Assuming it is, and you’ve granted root permission, then the exact command to turn off the device will depend on the specific manufacturer and Android version.
You can try some of the following:
svc power shutdown
am start -a android.intent.action.ACTION_REQUEST_SHUTDOWN
setprop sys.powerctl shutdown
Google may be able to offer specific commands for your particular Android device.