Back up your data with Time Machine or another backup method
Sign out of iCloud, Messages, and any other Apple services
Open System Settings or System Preferences
Go to General
Select Transfer or Reset
Choose Erase All Content and Settings
Enter your administrator password
Follow the on-screen prompts to erase the iMac
Wait for the reset process to complete
Restart the iMac
Set up the iMac as new or shut it down for the next owner
