setDebugDrawMask to DEBUGDRAW_NONE

If you set the mask to none (DEBUGDRAW_NONE) and you have not already set the mask your program will terminate.
The following code is safe

function gameClass:debugNone()
    local pw = cc.Director:getInstance():getRunningScene():getPhysicsWorld()
    if pw:getDebugDrawMask() ~= cc.PhysicsWorld.DEBUGDRAW_NONE then 
        pw:setDebugDrawMask(cc.PhysicsWorld.DEBUGDRAW_NONE) 
    end
end

Good luck
Andre