While at first glance confusing, all we have do remember is that if the domain of the function was a compact (i.e. closed and bounded) interval, the function would have to have an absolute maximum. Hence, to construct a counterexample, we need to define a continuous function on an open, bounded interval. The rest is easy, and left as an exercise.
These examples show that the closedness condition in the Max/Min theorem for continuous functions is essential.