Is There Any Way to Hide the Context Menu Based on License Status?

In our application there is a context menu, upon clicking which some functionalities are executed. In VAF, we could stop all the things (extension methods, background jobs) running when the license status is not what we are looking for.

But we want to hide the context menu as well, for that we tried calling extension method to check license status. The approach doesn't work properly, like shows or hides the menu sometimes when it shouldn't be shown. 

Is there any good approach to hide the context menu?