Figure out why they are barking
Different barking needs different fixes. Alert barking at the window is territorial and self-rewarding: the mail carrier always leaves, so the dog thinks the barking worked. Demand barking at you is attention-seeking. Boredom barking when alone is an unmet-needs problem. Listen for a week and note the pattern before you train, because training the wrong cause wastes everyone's time.
Manage first, train second
While you train, reduce the rehearsal. Close the blinds or use frosted window film if the trigger is passersby. Leave background noise or a food puzzle when you go out. A dog who barks at the window fifty times a day is practicing the habit you are trying to break. Management is not giving up. It is what makes training possible.
Teach the quiet cue
Wait for a natural barking moment, or have a helper knock. Let your dog bark two or three times, then say "quiet" once in a calm, low voice. Hold a treat near their nose. Most dogs stop to sniff. The instant there is even one second of silence, say "yes" and treat. Repeat, gradually asking for two seconds, then five, then ten before the treat.
Practice in short sessions when the dog is under threshold, not mid-meltdown at the window. Once the cue works in easy situations, proof it against harder ones one step at a time.
What not to do
Do not yell "quiet" at a barking dog. To the dog, you are barking along, which confirms that this is indeed a barking situation. Skip bark collars (shock, citronella, ultrasonic): they suppress the symptom through fear or pain without addressing the cause, and they can increase anxiety and aggression. If someone suggests debarking surgery, find a new advisor.
When barking signals a bigger problem
Barking paired with destruction, drooling, or panic when left alone points to separation anxiety, not a training gap. Barking that suddenly increases in a senior dog can signal pain or cognitive changes. Both deserve a vet visit before more training.