Consider this solved from a hardware perspective: (You will need to write your own code that watched GPIO pins to handle a shutdown)
See the breadboard diagram below:
pnp transistor: BC516
resistor: 100Kohm (I may use a 1Mohm in my final)
electrolytic capacitor: 220 uF (I may use 47 uF or less in my final)
so, I needed this function for the powerboost 1000C, but it will work on either the 500C or the 1000C. I did my testing on the 500C, but it will make little to no difference.
Basically the capacitor is charged when the spdt throw switch connect the BAT pin to the + terminal of the capacitor. When the capacitor is charged, it discharges through the 100K ohm resistor. the pnp transistor monitors this circuit, and is inhibited as long as there is power discharging through the resistor. if the pnp were not inhibited, the EN and GND pins would be tied together and shut down the powerboost. (note, on the 1000C, the BAT pin is labeled Vsh, and is not always the battery voltage, but the higher of two possible voltages. It shouldn't change the behaviour of this circuit, but the pins aren't the same, and this should help avoid confusion)
As long as the switch is closed, power continues to be applied.
When the switch is open, the capacitor stops charging, and begins to discharge. It discharges over time based on the value of the capacitor, and the resistor. If you modify these values, you can change the time. I need about 25 seconds, and this circuit on the first go gives me 38 seconds. once the capacitor discharges, the pnp stops being inhibited, and the EN and GND pins of the powerboost connect, killing power to everything.
So. If you want to integrate this into an rPI project, you will need to monitor the state of the power switch which charges the capacitor over one of your GPIO. You may need a voltage drop as the BAT pin can be as high as a fully charged lipo, exceeding the 3.3V considered "safe" on the raspberry pi. When the monitor pin goes low, a shutdown command is initiated.
Another consideration is that the voltage of the battery will change over time, hence changing the amount of power stored in the capacitor. This means that a lower battery will have a shorter shutdown time, so I'm planning on making my shutdown time much longer than needed.
On a device that has hours of battery life, an extra minute at full charge is nothing if it guarantees me the 25 seconds I require at low charge.
Another consideration is power consumption. When the switch is turned on, your resistor is chewing up battery. This is what is pushing me towards a 1M ohm resistor, and a smaller capacitor than a lower resistance, and higher capacitance. I want my timer circuit to demand maximum of about 5 mA continuously... the less the better.
Some useful places to check out while pursuing this are:
http://www.rapidtables.com/calc/electri ... ulator.htm
Here is a video of my breadboarded 500C operating on a 10 second shutdown:
The original post on this wasn't too far off the mark.
To get what I needed timewise, I ended up with a 1M ohm and a 47 uF. It gives me close to a minute on full charge. This should have a consumption near 2-4 mA, so not a huge imposition on the device.