When a cop sees a gun they have to back off and gain some distance before shooting. You don't want to pull your gun at close range as it can easily be knocked around and you end up shooting yourself.
Generally if a cop see a perp has a weapon such as a knife or gun - the proper procedure is to keep some distance if possible.