When to disconnect tubing in vacuum filtration?
If you were to turn off the pump while leaving the object attached then if you have an oil filled pump or a water pump then you will have a suck back which will either damage the pump or contaminate the thing you are filtering, or if you are very unlucky both.

If you have a house vacuum system then you should close the valve / tap between your filtration and the vacuum manifold before you remove the hose to your flask. If you do it the other way around then you will interfere with the use of the house vacuum by others.

I think you need to know if you have your own vacuum pump or if you are using a house vacuum system where a centralised pump serves many people.