TRUNK-3912 Task does not turn off automatically when uninstalling the module associated with it
(cherry picked from commit 48921ef55f65d97ff3b3df2eca59f1599ab06e1f)
TRUNK-3912 Code enhancements
(cherry picked from commit eb6cedee47bb5b4359ac1bd31b874952e0ab3e13)