Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Wish I could make the logouthook trick work...

I had a problem with this too.

You have to copy the txt into a plain txt file not rich txt format. In rich txt it won't work for some reason.

Also before - i was saving the txt file to my Users folder - when it should have been to my home folder.

Having sorted that - it worked fine for me.
Its certainly speeded shutdown on this iMac.
 
Thanks Ricede,
You pointed me in the right direction. I did manage to get this working with your hints. My MBPro now shuts down in @ 13 seconds, vs. the 30 seconds of before. At least it goes dark before the buffering thing starts spinning. Still not the sub 5 seconds of Mavericks unfortunately. Thanks again!
 
never tried on osx, but it may work

open terminal
sudo kill -9 -1 0
type password

should shut down pretty much instantly ;)
 
Unfortunately the clever logouthook script fix no longer works in 10.11 El Capitan, because the com.apple.loginwindow.plist file is in /System/Library/Launchdaemons and this is a protected area even sudo privileges cannot write to. What's worse, the old plist file from Mavericks and Yosemite is replaced by a virgin plist for El Capitan.
 
Did you try to disable SIP in the recovery partition? After that, the com.apple.loginwindow.plist is no longer protected.
 
i think i figured it out. It is doing all my iCloud updates etc so i can share with my other computer. I made a new user that does not have i cloud and it shuts down immediately.
 
You could be right. I also have a second admin-privilege user created, and it has no delay in shutting down. But if I disconnect the network (or boot without it connected) the shutdown problem doesn't go away for me as the normal user. Also, it is something to do with Apple software, as if I boot in safe mode (none of my normal applications running) the problem persists. The delay appears to be something that is holding up the UserEventAgent process (usual 20 second delay before being killed) but I've not yet been able to identify what the cause is.
 
Did you try to disable SIP in the recovery partition? After that, the com.apple.loginwindow.plist is no longer protected.
Yes!!!! It worked once I disabled the SIP system. One thing, though, I needed to put the full path /System/Library/LaunchDaemons/com.apple.loginwindow in the sudo defaults write command, otherwise it didn't find the file.

Now I have fast shutdown back. Thanks.
 
  • Like
Reactions: h9826790
&^%$#%$@^%&^*&!!!! I spoke too soon. I tested logout and shutdown within 20 or so seconds of booting. No problem, quick shutdown. But wait for 30 seconds or so and something tries to start that makes the UserEventAgent process wait 20 seconds at logout/shutdownbefore killing it. Whatever it is seems to take between 25 and 30seconds to commence. Should make diagnosing the Console logs a bit simpler, but a lot is going on at that time. Ah, well... back to the drawing board.
 
Dear all,
I have problem about shutdown time in 10.9. I have modified
sudo defaults write /System/Library/LaunchDaemons/com.apple.coreservices.appleevents ExitTimeOut -int 1

sudo defaults write /System/Library/LaunchDaemons/com.apple.securityd ExitTimeOut -int 1

sudo defaults write /System/Library/LaunchDaemons/com.apple.mDNSResponder ExitTimeOut -int 1

sudo defaults write /System/Library/LaunchDaemons/com.apple.diskarbitrationd ExitTimeOut -int 1

sudo defaults write /System/Library/LaunchAgents/com.apple.coreservices.appleid.authentication ExitTimeOut -int 1
That's ok in after do it once. But 2, 3 times is doesn't work. Every one have same issue please help me!
After that, you have to run a permission repair of Macintosh HD and finally restart.
 
Last edited:
Solution for slow shutdown of OSX

1. Open Terminal and execute following command to create LogoutHook

sudo defaults write com.apple.loginwindow LogoutHook ~/.logouthook

2. Create text file logouthook.txt with the following content (replace <your user-id> with your real user name)

#!/bin/bash
echo $'\n*** Shutdown ***\n' >>/users/<your user-id>/.shutdown.log
date >>/users/<your user-id>/.shutdown.log
echo $'\n all processes \n' >>/users/<your user-id>/.shutdown.log
ps -u <your user-id> >>/users/<your user-id>/.shutdown.log
killall -u <your user-id> -TERM&
sleep 1
echo $'\n 1 second after sending 1st TERM signal \n' >>/users/<your user-id>/.shutdown.log
ps -u <your user-id> >>/users/<your user-id>/.shutdown.log
killall -u <your user-id> -TERM&
sleep 1
echo $'\n 1 second after sending 2nd TERM signal \n' >>/users/<your user-id>/.shutdown.log
ps -u <your user-id> >>/users/<your user-id>/.shutdown.log
killall -u <your user-id> -KILL&


3. In the terminal to rename the file and make it executable

mv logouthook.txt .logouthook
chmod +x ~/.logouthook


The script works perfectly - shutdown time now constantly at 3 seconds - and the processes which ignored the TERM signals are listed in the logfile ~/.shutdown.log - one might use that info for further analysis.

the above works for OSX 10.8, 10.9, 10.10

Many thanks to Creditcard for this script.

This script works a treat for Mavericks slow shutdown with regards to the com.apple.launchd.peruser.501. One thing that confused me that should be noted is that in step 3. the file was moved (from my Desktop) and hidden as it becomes a system file (no title just .logouthook). No further action is required, your computer should shutdown much quicker now.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.