In quantum field theory (specifically when calculating free fermionic propagators via coherent state path integral), we encounter the following sum: $$I_{\beta}(\tau,\tau')\mathrel{\mathop:}= \frac{1}{\beta}\sum_{n=-\infty}^\infty \frac{e^{-i\omega_n(\tau-\tau')}}{-i\omega_n+E}$$ where $0\leq\tau'\leq\tau\leq\beta$ and $\omega_n=(2n+1)\frac{\pi}{\beta}$ is called the Matsubara frequency. We want to evaluate this sum, with the final answer being $$I_{\beta}(\tau,\tau')=\frac{e^{-E(\tau-\tau')}}{e^{-\beta E}+1}$$ While I am very close to obtaining this, I'm missing one step. Let me share what I have so far. I define two functions. The first is $$f_\beta(z)=\frac{\beta}{e^{-\beta z}+1}$$ which has infinitely many poles along the imaginary axis at $z_n=i\omega_n$. It is easy to show that $z_n$ is a simple pole, and that the residue of $f$ at $z_n$ is 1. Next, I define $$g(z;\tau,\tau')=\frac{e^{-z(\tau-\tau')}}{-z+E}$$ It clearly has a simple pole at $z=E$. I then define the region $S$ to be the rectangle going from $-i\infty$ to $+i\infty$ along the imaginary axis and $-x$ to $x$ along the real axis (where $x < E$ so that the pole of $g$ is not contained in $S$). By Cauchy residue theorem, $$\begin{align} \frac{1}{\beta}\oint_{\gamma=\partial S}\ \frac{dz}{2\pi i}\ g(z; \tau, \tau') f_\beta (z) &= \frac{1}{\beta}\sum_n \text{Res}\left[g(z)f(z), i\omega_n\right]\\ &= \frac{1}{\beta}\sum_n g(i\omega_n)\\ &= I_{\beta}(\tau,\tau') \end{align}$$ To evaluate the integral, we deform the contour $\gamma=\partial S$. The new contour consists of (i) an infinite counterclockwise circle and (ii) a small clockwise circle enclosing $E$ on the real axis (if this part is not clear I can elaborate). If we assume that the integral over (i) vanishes, then we are left with $$-\frac{1}{\beta}\text{Res}\left[g(z)f(z), E\right]$$ which matches the correct answer I gave above. The problem is that I do not see how the integral over (i) vanishes. We have $$\begin{align} \lim_{|z|\rightarrow \infty}\ \left|g(z;\tau,\tau')f_\beta (z)\right|&= \lim_{|z|\rightarrow \infty} \left|\frac{\beta}{-z+E}\right|\cdot\left|\frac{e^{z(\tau'-\tau)}}{e^{-\beta z}+1}\right|\\ \end{align}$$ But this is apparently not zero. For example, suppose $\tau'\neq\tau$. It seems the sign of the exponent in the numerator can be positive or negative depending on the sign of $\text{Re}(z)$. The infinite contour can be subdivided into two halves, one with positive real part and one with negative real part. So there is specifically a problem with the left half.
Am I not calculating this limit correctly? Alternatively, did I make a mistake elsewhere in my approach? Is there a better method/function to choose to evaluate the sum?