Fix task lifecycle