Smart shutdown for the Raspberry Pi