Runaway electron generation in a cooling plasma