how to delay windows shutdown to do shutdown jobs


i want to do some kind of backup und file cleanup, when the user
initiates a windows shutdown.

how can i stop windows from going down imediatily, so i can backup some
files before. If i wait for CloseQuery-Command, to do my jobs, windows
continues gowing down after 1 or 2 Minutes.