Set up a state run to die before executing the given state id,
    this instructs a running state to safely exit at a given
    state id. This needs to pass in the jid of the running state.
    If a state_id is not passed then the jid referenced will be safely exited
    at the beginning of the next state run.

    The given state id is the id got a given state execution, so given a state
    that looks like this:

    .. code-block:: yaml

        vim:
          pkg.installed: []

    The state_id to pass to `soft_kill` is `vim`

    CLI Examples:

    .. code-block:: bash

        salt '*' state.soft_kill 20171130110407769519
        salt '*' state.soft_kill 20171130110407769519 vim

def soft_kill(jid, state_id=None):
    '''
    Set up a state run to die before executing the given state id,
    this instructs a running state to safely exit at a given
    state id. This needs to pass in the jid of the running state.
    If a state_id is not passed then the jid referenced will be safely exited
    at the beginning of the next state run.

    The given state id is the id got a given state execution, so given a state
    that looks like this:

    .. code-block:: yaml

        vim:
          pkg.installed: []

    The state_id to pass to `soft_kill` is `vim`

    CLI Examples:

    .. code-block:: bash

        salt '*' state.soft_kill 20171130110407769519
        salt '*' state.soft_kill 20171130110407769519 vim
    '''
    jid = six.text_type(jid)
    if state_id is None:
        state_id = '__all__'
    data, pause_path = _get_pause(jid, state_id)
    data[state_id]['kill'] = True
    with salt.utils.files.fopen(pause_path, 'wb') as fp_:
        fp_.write(salt.utils.msgpack.dumps(data))