kmsloop: Avoid race condition while releasing loop

Change-Id: I9f6dc16ad75f634a17559684504078d3918f472c