It sounds like it's having trouble ending a processes or logging out of some service. Are you always connected to a server or some type of network when you try to log out? Before shutting down, unmount and disconnect all devices, log out of and shut down all network connections, and quit all applications. If any of those gives you an error saying it could not end xyz, then that's your restart problem. After that open activity monitor and see if there's any process still open that looks fishy. If not, quit activity monitor and try and restart. If it restarts without a problem now then the problem was one of those things you stopped or removed.