agent: Fix handling of rejected tasks.
agent: Fix handling of rejected tasks.

Fixes a problem introduced by removing TerminalState in #708

Signed-off-by: Andrea Luzzardi <442ffe3ffbfd024afcf0b7f8b108d05bca3aae43@gmail.com>

docker/swarmkit,yongtang/swarmkit,jlhawn/swarmkit,alyyousuf7/swarmkit,diogomonica/swarmkit,runshenzhu/swarmkit,Noyan759/swarmkit,aaronlehmann/swarmkit,AliyunContainerService/swarmkit,fate-grand-order/swarmkit,cezarsa/swarmkit,diogomonica/swarmkit,yp-engineering/swarmkit,runshenzhu/swarmkit,yp-engineering/swarmkit,sungwonh/swarmkit,RenaudWasTaken/swarmkit,dperny/swarmkit-1,deljuven/swarmkit,allencloud/swarmkit,cheyang/swarmkit,deljuven/swarmkit,jlhawn/swarmkit,alyyousuf7/swarmkit,dperny/swarmkit-1,Noyan759/swarmkit,vasil-yordanov/swarmkit,elifa/swarmkit,cheyang/swarmkit,AliyunContainerService/swarmkit,sungwonh/swarmkit,fate-grand-order/swarmkit,docker/swarmkit,vasil-yordanov/swarmkit,elifa/swarmkit,RenaudWasTaken/swarmkit,aaronlehmann/swarmkit,cezarsa/swarmkit,allencloud/swarmkit,yongtang/swarmkit