Also release lock in case of timeouts.