Bind window events on modal flag