handle close_figure better and reset the charting.CURRENT_FIGURE