def close_mpl_figure(fig):
    """Close a given matplotlib Figure. Any other type of figure is ignored"""
    import matplotlib.pyplot as plt
    from matplotlib.figure import Figure
    if isinstance(fig, Figure):
        plt.close(fig)
