Subaru Forester humming noise

'06 Forester, recently developed a high pitch humming sound when the car is turned OFF. Went to dealership twice, car didn’t make the noise. Technician told me to disconnect neg battery cable when car was making this noise to see if it would stop. It did, but mechanic still doesn’t know whats wrong…HELP