def check_and_remove_trailing_occurrence(txt_in, occurrence):
    """Check if a string ends with a given substring.  Remove it if so.

    :param txt_in: Input string
    :param occurrence: Substring to search for
    :return: Tuple of modified string and bool indicating if occurrence was found
    """
    n_occurrence = len(occurrence)
    if (txt_in[-n_occurrence:] == occurrence):
        txt_out = txt_in[0:-n_occurrence]
        flag_found = True
    else:
        txt_out = txt_in
        flag_found = False
    return txt_out, flag_found