How to stop mac from moving windows from external display to laptop when opening laptop lid
Welcome to Ask Different. I think your experimentation has you on the right track. If you drag a window to the external monitor before closing the lid on your laptop, it should stay on the external monitor after opening the lid again. You may also want to check which monitor you have as primary - that's where your desktop icons will first appear. In System Preferences, go to Displays and then click on the Arrangement tab. The display with the white bar on top is primary. You can drag that bar to the other display to make it primary.