Locking should be used when truncating and writing the history
file. (Yes, I know it's a pain in a portable program like
bash.)
Strictly speaking, locking is only half a solution, because
the net result will be that the saved history is taken from
a randomly chosen one of the multiple exiting shells. But
that's better than the current situation where all history is lost.
What might be cooler would be to merge all the history lines
from all shells, in timestamp order. But given the current
history file format, that seems...hard.