Hi Gary,
I use state to handle things like this. Highly recommend.
1) When your panel closes, update your state's panelStatus. Do this regardless of whether it closed via the `x` button or `close` button or another panel opening, etc. Each of these triggers an update to state.panelStatus. Perhaps also state.panelStatus maintains the states of multiple panels.
2) "React" to this state change accordingly from a single point in your code.
There's a react + Esri JS example here that I drew a lot of inspiration from, a fork of Rene's work (from Esri) https://github.com/coryeicher/jsapi-esm-react/tree/main.
We have used this approach with great success to build a React + Esri JS + Calcite component library.
Hope this helps,
CORY EICHER
www.eichcorp.com
cory@eichcorp.com