If you want to restore it to the closest possible version of the OS with which it shipped, do this:
First, sign out of iCloud, iTunes (de-authorize it), etc.
Then, boot to a SPECIAL VERSION of INTERNET recovery:
Command-SHIFT-OPTION-R
This will install the OS that the Mac originally shipped with, or the closest version to it that still works.
The internet utilities take a while to load, be patient.
You'll need your wifi password.
When the utilities load, open disk utility.
IMPORTANT: check to see if there's a view menu.
If there IS a view menu, choose "show all devices".
If there IS NOT a view menu, just continue on.
ERASE the internal drive to "Mac OS extended with journaling enabled, GUID partition format"
Quit disk utility and open the OS installer.
Start clicking through.
The Mac will restart one or more times, and the screen may go black for a few minutes, with no other indication of activity. Be patient.
When the OS install is done, you should see the initial login screen (choose your language).
At this point, try to quit out of it.
If it won't quit for you, just press the power on button CONTINUOUSLY until the screen goes dark.
When the new owner powers up, he/she should see the initial login screen once more...