If Mister LaForge can eject the Warp Core from the Enterprise in the event of a breach, surely Boeing can install a similar system to eject the battery in the event of fire.
The 787 would just have to be powered on impulse power, er .. I mean the RAT, until it can get to the next airport.