<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def is_state_machine_stopped_to_proceed(selected_sm_id=None, root_window=None):
 """ Check if state machine is stopped and in case request user by dialog how to proceed The function checks if a specific state machine or by default all state machines have stopped or finished execution. If a state machine is still running the user is ask by dialog window if those should be stopped or not. :param selected_sm_id: Specific state mine to check for :param root_window: Root window for dialog window :return: """

    # check if the/a state machine is still running
    if not state_machine_execution_engine.finished_or_stopped():
        if selected_sm_id is None or selected_sm_id == state_machine_manager.active_state_machine_id:

            message_string = "A state machine is still running. This state machine can only be refreshed" \
                             "when not longer running."
            dialog = RAFCONButtonDialog(message_string, ["Stop execution and refresh",
                                                         "Keep running and do not refresh"],
                                        message_type=Gtk.MessageType.QUESTION,
                                        parent=root_window)
            response_id = dialog.run()
            state_machine_stopped = False
            if response_id == 1:
                state_machine_execution_engine.stop()
                state_machine_stopped = True
            elif response_id == 2:
                logger.debug("State machine will stay running and no refresh will be performed!")
            dialog.destroy()

            return state_machine_stopped
    return True