The single best, safest advice I've seen is to download and use the free CCleaner. I've used it for my machines and those of my clients for numerous years without problems.
However, the problem you describe is almost unique in my experience. 10 to 30 minutes to shutdown?!
The few times I have experienced or seen that has been when there was some huge update taking place ... and in Win 7, these should always be visible as such.
Here are some questions, I haven't seen that need answers:
1. You mention that this started about two months ago. Can you recall any significant changes to your system about that time? Significant changes would be things like: the regular MS updates; installation of any new piece of software or any update; any repair shop work; any hardware addition (new printer, replacement drive, external drive). Any of these can have a direct or cascade effect (wherein one change leads to another leads to another, etc). If you tell us what these changes might have been, some member might know more about the possibilities.
2. One thing that used to call slowdowns was AV file scanning. About four years ago, the old Norton product used to get caught up in scanning each file within a huge compressed file (Zip files, backup files, Recovery files) and not relinquish control back to the computer until it was finished with the particular file, sometimes a matter of an hour or more! This was fixed by removing those enormous files from the scan process, but perhaps you have undone the default ...? It is something to think about.
3. Another think you haven't mentioned is how long your computer is on before you shut it down. The longer it is on, the more processes might be running in the background, the larger your swap file might be, and the greater the number of items on the clipboard.
4. In the same vein, you haven't given us an idea of what kind of software is running on your computer. Video (and even photo) editing can severely tap system resources. I remember years ago trying to rotate an image 2 degrees on an already straining computer. It was a thoughtless maneuver and it locked up my machine for an hour while trying to a) preserve the original in case I needed to revert and b) algebraically convert every pixel on a huge 1200 dpi image to its new position. I am a mathematician and yet I never contemplated the impact of that process.
5. Which makes me think, too, of yet another question: How old are your present apps? Older somewhat sometimes runs faster (because it is used to relying of fewer resources) and sometimes runs slower (because it can cope with coding changes and architectural differences). This would be something to consider if your problems began at the time of some upgrade of your system. Upgrades tend to accentuate the problems associated with out-of-date software and drivers. A good resource here is the free Secunia. Get it, and during installation opt for the passive choice in which Secunia has no right to make changes to your system. You will get great reports on applications and drivers on your system and the option to find your own appropriate upgrades or to accept the ones Secunia will find for you (usually the same ones -- it's just that I feel the user should be in charge).
6. Back-up programs tend to get somewhat possessive, too. Again, Symantec comes to mind with their old backup program -- a real memory hog, resource-sucking, bear of a program. Any such program that monitors changes and incorporates them into a compressed file or series of files finds itself juggling huge amounts of data -- and they don't want to be interrupted in midstream, nor should they be if you don't want corrupted backup data. The newer programs and mostly much, much more efficient, but still a change to some huge file that has been compressed, particularly by proprietary software may require the unraveling and re-raveling of the entire file, which can be quite lengthy. Once again, system files, particularly recovery files can be the culprit.
7. Check to see if you have two applications fighting each other over the same process. For example, two backup programs, if each is backing up the files of the other can wreak havoc. Likewise two system AV scanners could have a similar time-dampening impact. This might not have been intentional on your part. Both AOL and Comcast have, in the past, offered free software that sounds good, but that installs a bit more than you bargained for and in such a way you might not know if it's on or off.
8. A harddrive malfunction can produce these symptoms. I once had a harddrive that had a corrupted index in such a way that the C-drive (the system drive for me) was embedded within itself. Something like: C:\mydocuments\clientfiles\ABCCorporation\images\c\mydocuments\.... The culprit then was a sector that couldn't decide if it was bad or not and seemed to pass every test when I ran them, and then stayed healthy but too late to do me any good. Fortunately, I was able to copy all my files off to an external drive. The symptoms that exposed the problem to me was scanning slowdowns. Well, not just slowdowns, but scans that wouldn't terminate, because as soon as the indexer got to the lower level c, it just kept going through the entire structure again and again and ... Thank heaven for Ctrl-Alt-Del, but even that took a long time to take effect because my AV scanner was quite adamant about not letting go (and for good reason).
9. Check the size (and location, with multiple root directories) of your swapfile. A lot of vital information passes through a swapfile and MS will not let go of it until it is sure that information is safe. The physical movement of data with the extension indexing changes of large files can take large amounts of time.
Now, all this being said, and all the other good advice I've seen here, this is the suggestion that I think is best:
Yep, wipe your harddrive (if you're certain it's still a good drive) and reinstall every good piece of software you have.
Why? Because a thirty-minute shutdown that occurs more than once is a RED FLAG! Something is wrong, seriously wrong. Perhaps you can fix it; perhaps, not. But it shouldn't be happening at all. So don't risk it happening again, ... unless you can confidently pin the problem to an exact cause of which you are absolutely certain and which you have rectified (and even then I might think for at least a few minutes of reinstalling just for the heck of it).