If your contact sensor generates duplicate events, your theory seems plausible to me: you could get two instances of your app running at the same time, and if the second event fires before the first instantiation of the app finishes un-doing the subscription, then it will still be in place when the second "open" event happens, waking the app again. The first place I'd try to address this is at the driver level: what kind of contact sensor is this, and what driver is it using? This was an issue with some (primarily? all?) Z-Wave sensors a while back, and some drivers added an option to suppress these. That is better since it would apply to anything on the platform that uses these events, not just a specific app.
If that isn't possible, I suppose you could implement some app-specific workaround. The first thing I'd try would probably be saving something to
atomicState (I'd prefer this over
state given that the latter doesn't get written until the app finishes execution), maybe a "last executed" time that you could compare to the current time and some cooldown period of your choosing (or perhaps an option in the app).