If you Flatten an object that has the selectionLocking node, the selectionLocking node is removed but the exported UnSelectable attribute is not removed.
Even though the UnSelectable attribute exist, it is selectable with your plugin.
Is your plugin code looking for the selectionLocking node?
If so, maybe it would be better if it worked like your WebView works.
Edit:
The lock can be removed by either disabling the locking on the internal script or web ui window. For web ui locking, the lock can also be removed by select the locked node and uncheck the "UnSelectable" checkbox in the panel view.