kill x server

C++
sudo systemctl stop sddm.servicesudo systemctl restart lightdm.servicesudo service lightdm restart
Source

Also in C++: