Gmail Chat added a new status option: invisible. Now you can be logged in to Gmail Chat and see if your contacts are online, but they won't be able to see you're online.
If you simultaneously use Gmail Chat and any other flavor of Google Talk (the gadget or the desktop application), you won't be able to change your status to invisible because they don't support the new feature yet. The feature was first added to Gmail Chat because it's the most used interface for Google Talk, but it's unpardonable to have three separate interfaces with different features.
Note that feature is only available in the new version of Gmail, supported in Internet Explorer 7 and Firefox 2.