Game sharing and Share Play are two features that let you give a friend remote access to your library of games.
You should deactivate your PS4 so it's no longer associated with your account if you are selling or giving it away.