Fix unlocking bug

Seems like lock should be released at the end of a rerun.