Half-fill a bucket with water and a couple of squirts of dishwashing liquid. Keep the lid handy.
Remove everything you can from the attic, picking off the stinkbugs as you do. Put them into the bucket and replace the lid.
Vacuum or sweep up all the remaining stinkbugs. Empty the vacuum cleaner or the shovel into the bucket periodically. Check behind and under furniture for elusive stinkbugs. If you are using a vacuum cleaner with bags, seal them tightly and dispose of in an outside garbage can.
Empty the bucket outside at a good distance from your house. Most of the bugs should have drowned but some might survive. The dishwashing liquid forms a mild insecticide but breaks down harmlessly in your garden.
Caulk gaps around the attic window. Squirt the caulk into the gap, smooth with a butter knife and sponge away any excess.
Fit an insect screen, available from home stores or garden centers, over the window if you regularly open it. Screw or tape into position as per the manufacturer’s instructions.
Insect-proof other external doors and windows in your home if stinkbugs are also getting in that way. Fit door sweeps on external doors and more insect screens on windows. Look for other potential entrances, such as gaps around pipes, and seal with the appropriate building materials, such as cement.