Always unlock the same session instance that was locked (#12481)

Change-Id: I15ff1177d827bc8fee9f8f723f9a288b0c3aea71