Redefined UI.runSafely so it throws an exception if session can't be locked (#11219)

Change-Id: I300bfb25c4040d0df18d3a11594efe2ce6b0679d