Restart with the same windows and programs open
This is a feature introduced back with Lion, and it is called Resume. 
When you are restarting you mac there is a popup menu, that is asking you if you want to reopen windows when logging back.
If you check this box, all the programs and windows should come back as it was.