I have been struggling with the bug that crashes KiCad as soon as you delete a locked track causing you to lose all your work since your last save.
I have however figured out a solution while they work on version 5.1.5 which, the main reason for the release of version 5.1.5 is exactly this issue.
When opening the Pcbnew saved file (XXX.kicad_pcb) with a text editor, I used Notepad++, I saw that at the end of each locked track, via or footprint they add " (status 40000)", so I just used the find and replace function of Notepad++ (ctrl+h) and replaced " (status 40000)" remember the space before the braces with nothing, make sure that you don’t have anything in the replace with field, not even a space