Added Lock release functions in a finally clause