Reusing the `onNewPopupPanel` function to close existing popup panels (if any) before switching to a new side view. Alse closing any confirmation prompt.