One of the things that you might try is that the property node for front panels includes the Front Panel Open property that you can READ to see if the panel is open before you try to close it. It's a boolean so easy to build a case structure after it.
Hope this helps.
Rob
