I've configured my server for WakeOnLan and I'm logging in to it through a laptop on the same network.
The issue is, whenever I execute a command
shutdown -h now, the server reboots instead of shutting down. The second time when I shutdown, it functions properly.
Also, I've noticed that such a thing happens when the server is booted from laptop using a magic packet.