Just found the fix on this thread. I had to change set completed of aTask to true to mark complete aTask.
set completed of aTask to true
mark complete aTask