Why does loginwindow keep freezing in Mojave?
I've noticed the exact same hanging loginwindow issue since upgrading to Mojave 10.14.5. As @Dev and some of the other responses pointed out, there are some common applications which seem to contribute to this. Little Snitch is the culprit in my case and have found the following solutions work best as a workaround. My system is also configured for automatic login.

The immediate solution to fix the  hanging loginwindow is to ssh into the host which hangs and run this simple script (or one-liner) to stop loginwindow and then start it again using launchctl.

#!/bin/sh
sudo launchctl stop com.apple.loginwindow
sleep 2
sudo launchctl start com.apple.loginwindow


OR

sudo launchctl stop com.apple.loginwindow &amp;&amp; sleep 2 &amp;&amp; sudo launchctl start com.apple.loginwindow


The long-term workaround solution until Objective Development and/or Apple addresses this problematic behavior in their code is to instrument a launch daemon which executes a modified version of the above script at startup.


Create script in /usr/local/bin named fixHang.sh

sudo touch /usr/local/bin/fixHang.sh

Edit the script and paste in the content below.

sudo nano /usr/local/bin/fixHang.sh


#!/bin/sh
logFile="/Users/Michael/loginwindowdaemonscript.txt"
echo "------------BOOT BEGIN $(date)----------"
ustart=$(date -j -f "%a %b %d %T %Z %Y" "date" "+%s")
timestamp=$(date)
loginPIDChar=$(ps -ef | grep -v "grep" | grep "/usr/libexec/UserEventAgent (Aqua)" | awk $'{print $2}' | wc | awk $'{print $1}')
loginPID=$(ps -ef | grep -v "grep" | grep "/usr/libexec/UserEventAgent (Aqua)" | awk $'{print $2}')
echo "$(date) - START" >> "$logFile"
echo "$(date) - loginwindow PID: $loginPIDWindow" >> "$logFile"
echo "$(date) - UserEventAgentAqua PID: $loginPID" >> "$logFile"
while [ "$loginPIDChar" == "0" ];
do
        echo "$(date) - BEGIN LOOP" >> "$logFile"
        sleep 2
        echo "BEGIN CHECK" >> "$logFile"
        loginPIDChar=$(ps -ef | grep -v "grep" | grep "/usr/libexec/UserEventAgent (Aqua)" | awk $'{print $2}' | wc | awk $'{print $1}')
        loginWindowPID=$(pgrep loginwindow)
        echo "$loginWindowPID" >> "$logFile"
        echo "loginPIDChar = $loginPIDChar" >> "$logFile"
        if [ "$loginPIDChar" != 0 ];
        then
                timestamp=$(date)
                loginWindowPID=$(pgrep loginwindow)
                echo "$timestamp - KILL PROCESS # $loginWindowPID" >> "$logFile"
                sudo kill -9 "$loginWindowPID"
                sleep 5
                echo "$timestamp - BREAK LOOP" >> "$logFile"
                break
        else
                timestamp=$(date)
                loginWindowPID=$(pgrep loginwindow)
                echo "$timestamp - PROCESS NUMBER: $loginWindowPID" >> "$logFile"
        fi
        sleep 2
        echo "$(date) - END LOOP" >> "$logFile"
done
sleep 5
newloginWindowPID=$(pgrep loginwindow)
uend=$(date -j -f "%a %b %d %T %Z %Y" "date" "+%s")
echo "$(date) - fixDuration: $((uend - ustart)) seconds" >> "$logFile"
echo "$(date) - oldLoginWindowPID #: $loginWindowPID" >> "$logFile"
echo "$(date) - newLoginWindowPID #: $newloginWindowPID" >> "$logFile"
echo "------------BOOT COMPLETE $(date)----------" >> "$logFile"


Save out the file (Ctrl+O + [ENTER]) and exit nano (Ctrl+X + [ENTER])


Make script executable and change ownership to root:wheel

sudo chmod +x /usr/local/bin/fixHang.sh
sudo chown root:wheel /usr/local/bin/fixHang.sh

Create a launch daemon in /Library/LaunchDaemons which when loaded will execute the fixHang.sh script on startup

sudo touch /Library/LaunchDaemons/com.startup.fixhang.plist
sudo nano /Library/LaunchDaemons/com.startup.fixhang.plist

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;com.startup.fixhang&lt;/string&gt;
    &lt;key&gt;LaunchOnlyOnce&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;LimitLoadToSessionType&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;Aqua&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;sh&lt;/string&gt;
        &lt;string&gt;-c&lt;/string&gt;
        &lt;string&gt;/usr/local/bin/fixHang.sh&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;



Save out the file (Ctrl+O + ENTER) and exit nano (Ctrl+X + ENTER)


Change ownership of /Library/LaunchDaemons/com.startup.fixhang.plist to root:wheel

sudo chown root:wheel /Library/LaunchDaemons/com.startup.fixhang.plist

Load the launch daemon for execution at startup

sudo launchctl load /Library/LaunchDaemons/com.startup.fixhang.plist