Session does not close page

Hello all,

I have several pages in my app. All pages perform in the same manner but one does not work. This is the norm:
In a button on the page that is being left (other than Main Page).

self.Visible = False
    frmMain.Show
    Session.KillMe("frmManageUserInterfaces") 

In Session this code exists:

   Dim i As Integer
  Dim n As Integer
  Dim P As Integer
  Dim Pg as String
  p = session.PageCount -1
  for i = p   DownTo 0 Step 1
    n = session.PageCount 
    Pg = Me.PageAtIndex(i).Name
    if Me.PageAtIndex(i).Name = PageToKill  Then
      Me.PageAtIndex(i).close
      p = session.PageCount
      Exit For
    end if
  next 
  
  frmMain.fldPageCount.Text = "Page Count = " + cstr(Session.PageCount)
  Return

ALL of the other pages are killed except for this one - frmManageUserInterfaces. Stepping through the code reveals that during the For-Next loop, the page IS found, and the code Me.PageAtIndex(i).close is executed (within the for-next). But the page remains, at least in the Session.PageCount. On exit from the application, the page does appear to be killed since it appears, at least in debug mode, that all pages are killed and the app is fully removed from memory.

Has anyone had similar experiences, or suggest what may be the problem? There is nothing special on this page - nothing different from the other pages that is…

Thanks all,
Tim

Just out of curiosity… Instead of all that code, why not just call self.close?

Only reason I can think of though, is if this page has the implicit instance box checked, unless you are specifically holding a reference to it somewhere else.

Hi Greg,
All of the pages have implicit instance checked…

I could not find a reference to this page anywhere else in the project either.
The reason for the code, was that the page(s) were not closing when using that code (RS 2012r2.1).

Tim