Back up any important data
Sign out of iCloud, iMessage, and other Apple services
Open System Settings or System Preferences
Go to General
Select Transfer or Reset
Choose Erase All Content and Settings
Follow the on-screen prompts
Enter your administrator password
Confirm the erase
Wait for the iMac to restart and erase
Set up the iMac as new or shut it down for the next user
