There are many ways to do this but this an easy way and also a simple way. This method is only on rooted device. Lets know about this.
Step:1 Download remote switch off apk file.
Step:2 Install and open it, it will ask you the current code, new code , retype new code.
Step:3 Your current code is null which means if you send a normal message with this code (null) your phone gets switch off.
Step:4 Before that allow root access to this app.
Now send a message to this phone, your should contain the code. Everything is right your phone gets switch off. You can change the code by your wish.
Hope this method is really useful to you. Love you 🙂