Puts lock releasing in finally blocks
Merge pull request #2068 from tinwelint/2.0-release-locks-fin

Puts lock releasing in finally blocks