Exit user in bash script

I'm writing a bunch of scripts to automatically configure Ubuntu and I want to run the code below to remove the white dots from the login screen:

sudo xhost +SI:localuser:lightdm
sudo su lightdm -s /bin/bash
gsettings set com.canonical.unity-greeter draw-grid false

The problem is that as soon as this code is executed, it stays logged in as lightdm and the rest of the script doesn't run. I've tried to change the last command to this:

echo "exit" | gsettings set com.canonical.unity-greeter draw-grid false

but this doesn't seem to work and my script still stops running.

Is any one able to let me know where I'm going wrong?

My scripts can be found here:

Try

 sudo su lightdm -s /bin/bash -c "gsettings set com.canonical.unity-greeter draw-grid false"

Thanks a lot for that. I have a few other thing I'd like to do to improve my scripts, is here the best place to ask for advice?

Yes. Search these forums for similar problems and their solutions. Open a new thread for each of them if your search didn't succeed.