Update launchctl-env script to handle errors better and be restartable