I do something similar, try this;
[{"id":"dd52f866.edb3c8","type":"inject","z":"4487e413.bb781c","name":"System Shutdown","topic":"","payload":"sudo poweroff","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":140,"y":90,"wires":[["8f8e8089.058fa"]],"icon":"font-awesome/fa-power-off"},{"id":"b60d313.4c49bd","type":"inject","z":"4487e413.bb781c","name":"System Reboot","topic":"","payload":"sudo reboot","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":150,"y":130,"wires":[["8f8e8089.058fa"]],"icon":"font-awesome/fa-refresh"},{"id":"2ad017fa.99df08","type":"inject","z":"4487e413.bb781c","name":"Restart node-RED","topic":"","payload":"node-red-restart","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":170,"wires":[["8f8e8089.058fa"]],"icon":"font-awesome/fa-refresh"},{"id":"8f8e8089.058fa","type":"function","z":"4487e413.bb781c","name":"Countdown","func":"const input = msg.payload;\nconst cancel = false;\nvar desc;\nvar counter = 10;\n\nif (input == \"cancel\"){\n flow.set(\"cancel\", true);\n return;\n} else if (input == \"node-red-restart\"){\n desc = \"Restarting node-RED\";\n } else if (input == \"sudo reboot\"){\n desc = \"Rebooting system\";\n } else if (input == \"sudo poweroff\"){\n desc = \"Shutting down system\";\n } else {return;}\n\nvar countdown = setInterval(function(){\n node.status({text:(desc+\" in \"+counter+\" seconds\")});\n counter--;\n if (flow.get(\"cancel\")===true) {\n clearInterval(countdown);\n node.status({text:\"Request Cancelled\"});\n flow.set(\"cancel\", false);\n }\n \n if (counter === -1) {\n node.status({text:(desc+\" NOW!\")});\n clearInterval(countdown);\n node.send({\"payload\": input});\n }\n}, 1000);","outputs":1,"noerr":0,"x":370,"y":153,"wires":[["f560bf46.4c304"]],"icon":"font-awesome/fa-hourglass-1"},{"id":"c06193e0.c2a49","type":"inject","z":"4487e413.bb781c","name":"Cancel","topic":"","payload":"cancel","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":180,"y":210,"wires":[["8f8e8089.058fa"]],"icon":"font-awesome/fa-exclamation-triangle"},{"id":"f560bf46.4c304","type":"exec","z":"4487e413.bb781c","command":"","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"System Command","x":600,"y":150,"wires":[[],[],[]]}]