Hello,
I noticed that index.lock is one time removed by git-update-index and the other time not (I am still trying to make the rename behave on my cygwin installation). The atexit callback removes .lock file uncoditionally, whether it was opened by the current process or not.
I fixed this with the attached (sorry, it's windows+firefox+gmail) patch.
The patch sets up atexit only if the file was opened successfully.