Use a tape measure to measure the length of the gap between the window and the wall that you need to fill.
Mark the measured length of the gap onto a piece of fiberglass batting with a pencil.
Cut the batting with a utility knife along the penciled line. Test the fit of the batting in the gap for length and width. The batting should be wide enough to fill the gap while leaving a space of about 1/4 inch from the top of the batting to the surface of the window frame for the caulk seal. Adjust the batting to fit the gap if necessary using the utility knife.
Stuff the batting into the gap, fitting the batting snugly in place without causing pressure on the window frame.
Fill the space above the batting with silicone caulk, injecting the caulk over the batting and up to the surface of the frame. Smooth the caulk over the edge of the frame and the wall slightly to avoid any cracks over the gap, using a wet finger.