To kill the X server

To get the pid of the X server, use:

ps aux | grep "X"

Then execute:

sudo kill <X server pid>