Added shutdown sequence

Added a switch that, when it is ACTIVATED, closed the SD card and makes
sure that the card is not messed up.