gitk: Avoid crash if closed while reading references