To simplest way is possibly using
system[
^] call to issue the
shutdown
command appropriate for your operative system.
for instance
system("shutdown -h now");
on
Linux
(Please note: you must have the appropriate privileges, in order to successfully issue the command).