Well that isn't good... The P4 batteries can certainly be a bit weird to get snapped in right sometimes which leads us to obsessive checking and rechecking and it wouldn't be the first time that we have heard of the batteries coming out during flight.
But... The fact that it happens at the end of the flight is a bit telling though. If your battery isn't calibrated properly it will report that its state of charge is different from what it actually is which can cause issues. Dropping out of the sky is not usually one of those issues but it is possible. Every 15 flights or so we take the batteries down to 6-8% and then charge them on on the single DJI charger to make sure the totalizing circuitry is accurate.
Or birds. Or grit in the motors. Or props flying off. Gravity storms. Who knows The list is endless. Without more investigation/information it is hard to say. If you can get the .DAT files off the aircraft and send that to DJI they may be able to tell you more.