Hey Jon,
Most likely the issue has to do with some reference or object that is being opened on the first run without being closed. First, look through your code for any references that are not being closed appropriately. Then what I would recommend is to try a sort of binary search debugging procedure. That is, start by commenting your code to reach a very small, simple program that pretty much does very basic functionality (open panel, discard panel, etc). If this works, slowly uncomment code until you reach that point where you realize what reference is not being closed.
Hope this advice helps!
Thanks,
Andy McRorie
NI R&D