instead please replace with this code snippet, this is the suggested way.
aspect.before(measurement, "setTool", function(method) {
// always deactivate draw when switching tools - even if turning measurement tool off
// this also prevents draw from destroying necessary map event listeners that the measurement widget relies on
draw.deactivate();
});
aspect.after(measurement, "setTool", function(method) {
// re-activate draw if theres no active measure tool after setTool logic completes
if (!measurement.activeTool) {
draw.activate(Draw.LINE);
}
});