Pimoroni put together a one-line-installer to install the clean shutdown daemon. It watches the state of BCM pin 17 and, when pulled low (pressed), it initiates a clean shutdown. Last thing, just before your Pi shuts down, BCM pin 4 is pulled low to completely cut power to your Pi.
To install the software, open a terminal and type
curl https://get.pimoroni.com/onoffshim | bash to run the one-line-installer.