The easiest way to restart X-windows is to simultaneously press ctrl-alt-backspace. Note: this will instantly kill X-windows and any programs running within it, like your window manager and probably everything else. There will be no confirmation.
Note: Since Ubuntu 10.04 the keystroke "ctrl" + "alt" + "backspace" has been disabled. The default shortcut is now "alt"+"print screen"+"k" (More info is here at restart X server. )
Alternatively, from the command-line, type "sudo pkill X".
Alternatively, from the command-line, type "/etc/init.d/gdm restart" (or "/etc/init.d/xdm restart" or "/etc/init.d/kdm restart").