Fixes scope defer issue with window resizing