This issue may happen when Windows takes much time to end the Windows programs which run in the background. Do one thing, take a backup of the registry and do the following changes. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control and you will see a registry key named WaitToKillAppTimeout in the right pane. Double click on it. Edit string window will be opened. In the Value Data: give a new value "1000" and press OK.
Try the above method and tell me what happens, if this does not work, go to safe mode and then try to shut down from there and tell me what happens.
I tested it on Vista and 7, it worked well, not sure about XP. Its been a long time i used it, do try and let me know mate, we can fix the issue, not to worry.