def clean_closed_channels(output):
    """Cleans up the list returned by command ":ROUTe:CLOSe?", such that each entry is an integer denoting
    the channel number.
    """
    if isinstance(output, str):
        s = output.replace('(', '').replace(')', '').replace('@', '')
        if s == '':
            return []
        else:
            return [int(s)]
    elif isinstance(output, list):
        list_final = []
        for i, entry in enumerate(output):
            if isinstance(entry, float) or isinstance(entry, int):
                list_final += [int(entry)]
            elif isinstance(entry, str):
                list_final += [int(entry.replace('(', '').replace(')', '').
                    replace('@', ''))]
            else:
                raise ValueError('Every entry must be a string, float, or int')
            assert isinstance(list_final[i], int)
        return list_final
    else:
        raise ValueError('`output` must be a string or list.')
