You should simply add your UI's toplevel control to a new fragment and then add the fragment to the base vanilla games existing scenes for the "Ui shown" and "UI hidden -> In menus".
Lua Code:
local fragmentOfYourAddon = ZO_HUDFadeSceneFragment:New(YourTopLevelControlNameHere, nil, 0)
HUD_SCENE:AddFragment(fragmentOfYourAddon )
HUD_UI_SCENE:AddFragment(fragmentOfYourAddon )
This will automatically hide and show your TLC YourTopLevelControlNameHere as the users presses ESC or I or U etc. and a menu is shown, and show it again after they closed that.
Read more about scenes and fragments here:
https://wiki.esoui.com/Scene_Manager:_On_scene_change
https://wiki.esoui.com/Fragments_in_...t_state_change