anchor.diff:      gen_server:reply( Device#device.started_by, Msg ).
   
   handle_stop( shutdown, DeviceId, State ) ->
  +    reply_stop( DeviceId, State ),
       Devices = orddict:erase( DeviceId, State#state.devices ),
       State#state{ devices = Devices };
   
   handle_stop( _Error, DeviceId, State ) ->
  +    reply_stop( DeviceId, State ),
       Devices = orddict:update(
           DeviceId,
           fun( D ) -> D#device{ os_pid = undefined, state = crashed } end,
           State#state.devices
       ),
       State#state{ devices = Devices }.
  +
  +reply_stop( DeviceId, State ) ->
  +    Device = orddict:fetch( DeviceId, State#state.devices ),
  +    reply_stop( Device#device.stopped_by ).
  +
  +% This can happen when there was device stop requested,
  +% however the device has exited meanwhile.
  +reply_stop( undefined ) -> ok;
  +reply_stop( From ) -> gen_server:reply( From, ok ).
  +
   
   handle_poll( _Msg, _DeviceId, State ) ->
       % FIXME - propagate to subscribers
  
positive.code:             { ok, Id }
          end
      ),
      meck:expect( lurch_device, stop, 1, ok ).
  
  setup_server_stop( _ ) ->
      setup_meck_stop( ok ),
  
negative.code: test_stop_response( ok ) ->
      Id = make_ref(),
      Id2 = make_ref(),
      Device = #device{ id = Id, state = running,
                        stopped_by = { make_ref(), self() } },
      Devices = orddict:store( Id, Device, orddict:new() ),
      S0 = #state{ devices = Devices },
  
  