There are two main ways. The simplest one is to click Friends in the menu bar and choose Invisible (you are online but unseen to other users) or Offline (you are online but you are not listed as a Friend/Chat). Alternatively, press Friends and Chat in the lower right, press the arrow beside your name and select Invisible or Offline.