A new Apple Knowledge Base article advises that before you sell or give away your Mac, you need to back up and remove your data from your computer to keep the data safe, and deauthorize your computer from iTunes if applicable.
The article describes how to back up and remove your data from your Mac before selling it or giving it away, and notes that you should not manually delete contacts, calendars, reminders, documents, photo streams, or any other iCloud data while signed in to your iCloud account. Doing so will not only delete that information from your Mac, but will also delete it from the iCloud servers and any other devices you also sync with iCloud. Instead, follow the steps below to remove your iCloud account from your Mac and leave your iCloud data intact on your other devices.
You can check it out at: