anchor.diff:      epoch_mining:error("Unknown miner finished: ~p~n", [Miner]),
       {keep_state, State#state{ miner = OtherMiner }};
   running(cast, create_block_candidate, State) ->
  -    {next_state, configure, State, [postpone]};
  +    kill_miner(State#state.miner),
  +    {next_state, configure, State#state{miner = none}, [postpone]};
   running(cast, bump_initial_cycle_nonce, State) ->
  -    {next_state, configure, State, [postpone]};
  +    kill_miner(State#state.miner),
  +    {next_state, configure, State#state{miner = none}, [postpone]};
   running(cast, mine, #state{block_candidate = BlockCandidate,
                              initial_cycle_nonce = CurrentMiningNonce,
                              miner = none}
  
positive.code:     {keep_state, State, [{reply, From, ok}]};
  running({call, From}, suspend, State) ->
      epoch_mining:info("Mining suspended by user.", []),
      {next_state, idle, State, [{reply, From, ok}]};
  
  %% Casts: post_block | miner_done | create_block_candidate |
  %%        bump_initial_cycle_nonce | mine | check_keys
  
negative.code: mine_event()          -> cast_event(mine).
  cast_event(Msg)       -> next_event(cast, Msg).
  next_event(Type, Msg) -> {next_event, Type, Msg}.
  
  kill_miner(none) ->
      ok;
  kill_miner(P) when is_pid(P) ->
      exit(P, normal),
      ok.
  