KER-258: Release properly the locks