I don't think there is a "correct" way to do this. But what you did is
exactly what I would do as well. If you can use sudo un the machine in
question, just do
sudo /etc/init.r/{x|d|k}dm restart
to restart the login manager. Every running X session (and child
processes) will be killed that way.
I would not suggest restarting the login manager. Any X app you are
running that has any state (think mozilla, openoffice, etc.) will not
get a chance to safely shutdown, and can cause corruption and/or lost
data.