How to automatically shutdown your system after certain duration of time

How to automatically shutdown your system after certain duration of time ?

What happen sometimes you work on your computer and you know whatever the task you are doing (eg. downloading games) will take how much time and you have to do some other work in that time or go outside or you may sleep so, in that case you can set the timer to automatically shutdown the system.