How can I force a Mac laptop to shutdown when the battery is below 25%?
I haven't tested this, although something such as this should work:

property lowBattery : 25

on idle
    set battStatus to do shell script "pmset -g ps"
    if battStatus contains "InternalBattery" then
        set {TID, text item delimiters} to {text item delimiters, ";"}
        set battStatus to text items of battStatus
        set text item delimiters to space
        set battStatus to text 1 thru -2 of last text item of item 1 of battStatus as integer
        set text item delimiters to TID
        -- Shutdown if battery is less than 25%
        if battStatus &lt; lowBattery then tell application "loginwindow" to «event aevtrsdn»
    end if
    return 60
end idle


In AppleScript editor save it as an Application using Stay open run handler, then add it to your Login Items under System Preferences &gt; Users &amp; Groups