     if Enum.empty?(state.receiver_queue) do
       case :inet.setopts(state.sock, active: false) do
         :ok -> :ok
-        error -> {:disconnect, error, {:error, :closed}, state}
+        error -> {:disconnect, error, error_response(state), state}
       end
     else
       :ok

        :ok = Receiver.read_quiet(s.receiver, from, Enum.reverse([{i, :NOOP, [], []} | commands]))
        {:noreply, s}

      {:error, _reason} = error ->
        {:disconnect, error, error, s}
    end
  end



    if receiver_queue do
      Enum.each(receiver_queue, fn from ->
        Connection.reply(from, error_response(s))
      end)
    end

    :ok
  end

  defp error_response(%State{server: server}, reason \\ :closed) do
    {{:error, reason}, %{server: server}}
  end

  defp maybe_activate_sock(state) do
