def METHOD_NAME(object, name, old, destroyed):
    """Remove the UI object from KEEP_ALIVE_UIS."""
    assert name == "destroyed"
    if destroyed:
        assert object in KEEP_ALIVE_UIS
        KEEP_ALIVE_UIS.remove(object)
        object.on_trait_change(METHOD_NAME, "destroyed", remove=True)