If you haven't already realized, the Raspberry pi has no power switch like your normal PC. Many people simply unplug their Raspberry Pi, but there is a much safer way to shutdown your device without risking losing data or corrupting your SD card.

Safely Shutdown Your Raspberry Pi
sudo shutdown -h now
-h will halt the system
now will do it immediately

The shorthand for this command is simply: sudo halt

You can also tell your device to shutdown in a certain number of minutes:
sudo shutdown -h 20
This is telling your device to shutdown in 20 minutes. Replace 20with time in the format of hh:mm on the 24hr clock to specify when your would like to shutdown exactly (ex. sudo shutdown -h 16:30).

Safely Reboot Your Raspberry Pi
sudo shutdown -r now
-r will reboot the system
now will do it immediately

The shorthand for this command is: sudo reboot

By using these commands and not simply pulling the plug, you don't have to be concerned with corrupting your SD card or losing your data.