How To Fix PSI Exam Sidecar Relay Not Quit Error

If you're taking PSI Exams online using a MacOS computer, you may run into an error that prevents you from quitting the exam.
If you don't quit the SidecarRelay application, the testing software won't let you proceed. Here's how you can get this accomplished so you can proceed with the test.
Download a script
The issue with Sidecar relay is getting the SidecarRelay process to "stay terminated" can be a bit difficult. The easiest way to accomplish this is to run a script that will terminate the process when it starts, as the MacOS operating system appears to try to restart it. This is sufficient to get around the PSI Exam software checks.
Download and Execute Script
If you're in a hurry, you can run all the steps in one go like this and start your exam:
curl -o kill_processes.sh https://gist.githubusercontent.com/freshyjmp/33300039b98eda8da718ffbb62717532/raw/1e1fa9fd45c298da843a948a4693ba83c6b6d760/kill_processes.sh && chmod +x kill_processes.sh && screen -dmS process_killer ./kill_processes.sh
Alternatively, you can copy the script and create the file manually:
#!/bin/bash
# kill_processes.sh
while true; do
# List processes and filter out the grep command itself
pids=$(ps aux | grep -E 'SidecarRelay|photolibraryd' | grep -v grep | awk '{print $2}')
# Kill each matching process
for pid in $pids; do
echo "Killing process with PID: $pid"
kill -9 "$pid"
done
# Pause for 1 second before checking again
sleep 1
done
Run the script
If you didn't use the combined command above, run this command to start the script and get rid of SidecarRelay.
chmod +x kill_processes.sh && screen -dmS process_killer ./kill_processes.sh

Close the terminal and go back to your test.
After the test
If you want to get things back to how they were before, open a terminal again and run:
screen -S process_killer -X quit
Or, you can restart your computer.
Everything will return to the state it was before your exam.