I used to have something like this (Don't remember exactly)
Code:
Private Sub CloseProgram()
    While Forms.Count > 1
        Unload Forms(Forms.Count - 1)
        DoEvents
    End While
    Unload Me
End Sub
If you call this code from a form, this loop will keep open that form, so Forms.Count > 1 does the trick. If you're in a procedure like Sub Main and this code is NOT run inside a form then you can also change it to 0.

Best regards,
Xmas.