As far as I can tell (assumption), the context is automatically removed from Contexts[] when it becomes empty (has no characters). At least this happens in my tests. Here is one of them:
In[1]:= BeginPackage["Test`"] EndPackage[] Out[1]= Test` In[3]:= MemberQ[Contexts[],"Test`"] Out[3]= False In[4]:= Test`a Out[4]= a In[5]:= MemberQ[Contexts[],"Test`"] Out[5]= True In[6]:= Remove["Test`*"] In[7]:= MemberQ[Contexts[],"Test`"] Out[7]= False
It may also explain why the call to Contexts[] takes a significant fraction of a second - the system should check each context to see if it is empty. In any case, the answer to your question seems simple - delete all characters and the context will be removed from Contexts[] . This also works for contexts loaded by the system - you can try some ( XML' for example), although, of course, this is not a good practice, to say the least.
Leonid Shifrin
source share