A damaged vacuum hose, clogged motor air filter or bad suction motor can cause the vacuum cleaner to shut off during use.
A tripped overload on the vacuum suction motor can shut off the vacuum cleaner during use. If your vacuum has a reset button, push it; if the vacuum seems hot, let it cool off first. If the suction motor continues to trip the overload, you may need to replace the motor because the motor windings are bad. Bad windings could be causing the motor to overheat and trip the overload.
If the motor compartment has a motor air filter, check the condition of the air filter because a dirty filter can cause the suction motor to overheat. Clean or replace the motor air filter if it's dirty.
A damaged suction hose on a canister vacuum can cause the suction motor to shut off because the suction hose has integrated wires that carry current from the power switch to the suction motor relay. The suction motor will shut off if a wire loses continuity as you move the damaged hose during vacuuming. Replace the vacuum hose if it's damaged and an internal hose wire loses continuity during vacuuming.