As with services, Windows will also wait for a while, depending on WaitToKillAppTimeout setting, before starting to shut down and kill open applications and user processes when the user want to shutdown, restart or log off. The wait time or time out can be reduced to speed up the shutdown process.
Navigate to the following registry branch:

HKEY_CURRENT_USER\Control Panel\Desktop

On the right pane, double click on WaitToKillAppTimeout (or right click on the registry key and select Modify), and enter a new value which is less than the default value of 20000. The value can be 1000 or 5000 or any other numeric value, depending on your preference. When the WaitToKillAppTimeout registry entry timeout or expires, the End Task dialog box appears, stating that the process did not respond, and allowing user to End the task.

On the right pane also, double click on HungAppTimeout (or right click on the registry key and select Modify) and change the value to less numerical value than 5000 (default value), e.g. 1000. HungAppTimeout specifies how long the system waits for user processes to end after the user clicks the End Task command button in Task Manager or after the user has selected to restart or shutdown the system.

Then navigate to:

HKEY_USERS\.DEFAULT\Control Panel\Desktop\

registry branch, and do the same as above to change and modify the value of WaitToKillAppTimeout and HungAppTimeout registry keys.

Automatically end, terminate and kill user processes or tasks on shutdown or logoff

Even if you have set the HungAppTimeout registry entry to a very low value, what happen is that when HungAppTimeout time out due to a hung applications or unable to terminate tasks or not responding to the end task request, it will prompt user with a End Task dialog box to ask if user wish to end the process. By changing to the value of registry key AutoEndTasks to 1, we can ask Windows to end all processes that timeout when shut down or log out from Windows automatically, without asking for user input or interaction. Default value of the key is 0, which mean no user processes will end automatically.

AutoEndTasks is located at:

HKEY_CURRENT_USER\Control Panel\Desktop

registry branch.