Evaluate $\int^4_0 g(x) \text { d}x$ Evaluate $\int^4_0 g(x) \text { d}x$

Breaking this up into separate integrals, I got:
$$\int^4_0 g(x) \text { d}x = \int^1_0 x \text { d}x + \int^2_1 (x-1) \text { d}x + \int^3_2 (x-2) \text { d}x + \int^4_3 (x-3) \text { d}x$$
$$ = \frac{1}{2} + \frac{1}{2} + \frac{1}{2} + \frac{1}{2} = 2$$
However, is this correct? I ask because we have closed/open intervals and so I'm not sure how integration behaves on closed/open intervals.

You are most right.
As a result of its definition, the riemann integral does not change its value if you change a function in a finite set of points, because you can just choose a partition to have those troublesome points as boundaries of the intervals of the partition. Likewise, integrating  $f $ over the four intervals $[a, b]; [a, b); (a, b]; (a, b) $ yields the same result.
