Refactor closable-panel code

Reduce nesting for checking the class names of non-closable panels