If you are shutting down with Firefox running, try closing Firefox first and then shutting down.
I have found that when this happens to me, it is due to one or more active tabs having something going on in the background that has a file open or something and the kernel sits and waits for for the calling program to clean up its act...which never happens.
I really hate all the hidden stuff that goes on in tabs in Firefox now especially web sites that play multimedia adds with sound with no way to know which tab contains that annoying content.
Any way, if shutting down Firefox first helps, then go and shut down the open tabs a few at a time until you find the one that is causing the problem.
More often than not, it turns out that something on a web site is requesting a user response that the programmer thought was ultra important but does not appear in the foreground on your screen.
If that is not it, I don't have a clue.
Oh yeah, I posted this and then remembered the other time that I have seen this.
If you have synaptic open but on another desktop or not showing in the foreground, the same thing will happen.
Also, if you have changed something in "configure your desktop" but have not saved the results, the same thing will happen when you try to shut down.
The safest thing is to make certain that all programs are shut down and you are looking at an empty task bar before shutting down.