Make sure all chunks come before the exit msg.
Fix endless loop.

The problem here was the conditional state change in the 0-second timeout. If
the condition has not been met, the actor loops forever.

Initially, it looked like actor-framework/actor-framework#175 was the problem,
but as it turns out this was only symptomatic for the underlying issue, which
is fixed with this commit.
Prepare CMake for GCC 4.9.