Getting out of X

If you want to exit your X session normally and gracefully, there's generally a logout icon somewhere on the bottom panel.

If, however, your X session gets locked and you can't exit normally, try the key sequence Ctrl+Alt+Backspace, that's designed to abort the X session completely and dump you back at your original virtual console.