Made the insertion of the finished flag record more robust to handle simultaneous threads attempting to insert it.