How to know if an android device is turned off from the server?

Can I ping the android device from the server to know if it is turned off? I think there is no way to ping the server before the android device turns off. Particularly I will be doing this in node js

Thanks if you can guide me to the right path. Thanks!!

You could maintain a persistent connection using a Faye server. That way, you will get to know when your device switches off. As a fallback, use an sms confirmation, just in case the network is not down.

Node.js example here. https://github.com/faye/faye