Avoid this by using minimal expanding foam. It’s formulated to fill the space around windows and doors without excess expansion. Look for cans labeled for use on windows and doors. Another good ...