Detecting stale locks

Just tried some lock and unlocks here and there, these are my conclusion:

1- When a ‘restic backup’ is running it creates a lock
2- If you try do ‘restic unlock’ the last ‘restic backup’, restic won’t delete the lock, cause it is still running
3- If you try to start a new ‘restic backup’, restic will create a second backup instance and a second lock is created
4- If you ‘kill -9’ the first ‘restic backup’, the process will be suddenly killed (simulation a power loss) and the lock will keep in the repository
5- Running a new ‘restic backup’, restic won’t unlock the previous, it will create a new lock file
6- If you ‘restic unlock’, restic will remove the lock that was stalled

Based on these, some obvious, assumptions, it’s possible to create a good shell script to manage restic lock files.