There are some steps you have to take before moving to a new Mac. Besides the usual backup procedure, you also have to sign out of all the Apple's main apps. For example, you have to sign out from iTunes, iCloud, and iMessage.
Here are the procedures for each of the mentioned applications:
Deauthorize your Mac from iTunes
Open iTunes from the menu bar and then go to Account > Authorizations > Deauthorize This Computer. If prompted, enter your Apple ID and Password and then click on Deauthorize.
Sign out of iCloud
The iCloud feature provides the Find My Mac service that allows you to locate or lock your Mac. To sign out, click the Apple Menu > System Preferences > iCloud then deselect Find My Mac. To sign out, simply press the Sign Out button.
If you have data stored on your iCloud, after you click the Sign Out button you will be asked either to remove the data from your Mac or to keep it. Select to remove it while the iCloud data will remain intact.
Sign Out of iMessage
This is available for Mountain Lion or later. To sign out from iMessage, open the application then select Preferences > Account. Choose your iMessage account and click on Sign Out.
Wipe your Mac
Now it's the time to wipe your Mac and delete everything. The easiest way to do this is with the help of the Internet. Mac OSX can be reinstalled using the Internet. Here is what you have to do to achieve the goal:
1. Reboot your Mac and press Option-Command - R combo until the Apple logo appears. Wait a little, and the utilities menu should appear on the screen.
2. Click on Disk Utility, identify the main hard disk, and select it. Switch to the Erase tab and make sure it's formatted as Mac OS Extended (Journaled).
3. Go back to the main screen and click on Reinstall MacOS
4. Follow the instructions on the screen to select the disk where Mac OS will be installed, then sit back, and enjoy.
5. At the end of the installation, your Mac will restart. Do not continue past this step because if you plan to sell the device, the new owner needs to add his own details and information. Press Command-Q and select Shut Down.
Apple made it easier to format and reinstall the operating system, even if you don't have an installation disk because the Reinstall MacOS will simply use the Internet connection to download the necessary files. I've done this procedure many times without errors. The process duration depends on the performance of your device. At this point, the Mac is brand new and ready for selling.