Workflow displaying "This task is currently locked by a running workflow and cannot be edited"

When you try to change the status of Task List in SharePoint from Inprogress to Complete, you will be greeted with a good error message "Workflow displaying "This task is currently locked by a running workflow and cannot be edited".
 
Powershell commands to unlock all the task items. 
 
$web=$site.OpenWeb()
$web.url
$i=0
foreach($list in $web.lists)
{
foreach($item in $list.items | where
{$_[[Microsoft.SharePoint.SPBuiltInFieldId]::WorkFlowVersion] -ne 1})
{
if($item["Status"] -eq "In Progress")
{
$item[[Microsoft.SharePoint.SPBuiltInFieldId]::WorkFlowVersion]=1;
$item.Update()
$i++
}
}
}
$web.dispose()
$site.dispose()

 
Here Workflow version has to be at one to unlock all the workflow items.