5. Two players, A and B, are playing a table tennis match, with the agreement: the winner of each game gets 1 point, and the loser gets 0 points; the match stops when one player is 2 points ahead or after 6 games have been played. Suppose the probability of A winning each game is $\frac{3}{4}$, and the probability of B winning each game is $\frac{1}{4}$, and the outcomes of each game are independent. Then, the expected number of games $\mathrm{E} \xi$ played when the match stops is $\qquad$.
5. $\frac{97}{32}$.

From the problem, we know that all possible values of $\xi$ are $2, 4, 6$.
Let each two games be a round. Then the probability that the match stops at the end of this round is
$$
\left(\frac{3}{4}\right)^{2}+\left(\frac{1}{4}\right)^{2}=\frac{5}{8} \text {. }
$$

If the match continues after this round, then A and B must have each scored one point in this round, and the result of this round has no impact on whether the match stops in the next round. Therefore,
$$
\begin{array}{l}
P(\xi=2)=\frac{5}{8}, \\
P(\xi=4)=\frac{3}{8} \times \frac{5}{8}=\frac{15}{64}, \\
P(\xi=6)=\left(\frac{3}{8}\right)^{2}=\frac{9}{64} . \\
\text { Hence } \mathrm{E} \xi=2 \times \frac{5}{8}+4 \times \frac{15}{64}+6 \times \frac{9}{64}=\frac{97}{32} .
\end{array}
$$