Have you tried setting the engagement range to "Hold Position"?
By default, this is set to "Gravity Well" (so it engages anything and everything that is hostile in the gravity well), but can be set to "Local Area" (exactly how "local" is a mystery to me) and "Hold Position". The button has a large blue oval for the entire well, smaller green for local area, and I believe a small red X for hold position.