Answer
$W_{ext} = -1~J$
Energy is transferred from the system to the environment.
Work Step by Step
We can use conservation of energy to find $W_{ext}$:
$K_i+U_i+W_{ext} = K_f+U_f+\Delta E_{th}$
$W_{ext} = K_f+U_f+\Delta E_{th}-K_i-U_i$
$W_{ext} = (1~J)+(2~J)+(1~J) -(4~J)-(1~J)$
$W_{ext} = -1~J$
Since $W_{ext} \lt 0$, energy is transferred from the system to the environment.