Let us analyze the expression inside the modulus:
\[
f(x) = x^2 - x - 2 = (x - 2)(x + 1)
\]
So, the sign of \( f(x) \) changes at \( x = -1 \) and \( x = 2 \). On the interval \([-2, 2]\), break into regions:
1. \( x \in [-2, -1] \Rightarrow f(x) > 0 \) \
2. \( x \in [-1, 2] \Rightarrow f(x) < 0 \)
So:
\[
\int_{-2}^{2} |x^2 - x - 2| dx
= \int_{-2}^{-1} (x^2 - x - 2) dx - \int_{-1}^{2} (x^2 - x - 2) dx
\]
Now compute both integrals:
\[
\int_{-2}^{-1} (x^2 - x - 2) dx = \left[ \frac{x^3}{3} - \frac{x^2}{2} - 2x \right]_{-2}^{-1} = \left( \frac{-1}{3} - \frac{1}{2} + 2 \right) - \left( \frac{-8}{3} - 2 - (-4) \right) = \frac{13}{6}
\]
\[
\int_{-1}^{2} -(x^2 - x - 2) dx = \int_{-1}^{2} (-x^2 + x + 2) dx = \left[ -\frac{x^3}{3} + \frac{x^2}{2} + 2x \right]_{-1}^{2} = \frac{27}{6} = \frac{9}{2}
\]
Now add both:
\[
\frac{13}{6} + \frac{27}{6} = \frac{40}{3}
\]