<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def all_terminated():
 """For each remote shell determine if its terminated"""

    instances_found = False
    for i in all_instances():
        instances_found = True
        if i.state not in (remote_dispatcher.STATE_TERMINATED,
                           remote_dispatcher.STATE_DEAD):
            return False
    return instances_found