I've been doing this with my MBA M4 since day one: I turn off Wi-Fi and Bluetooth to prevent the network and my connected keyboard and mouse from interrupting the computer's sleep.

I configured Control+Command+S as a shortcut to put the computer to sleep. While playing a music video on YouTube, I pressed the shortcut and the music stopped. However, as soon as I moved the mouse or used the keyboard, the video started playing again, even while the computer was supposedly "asleep" (with the lid open or closed).

So, at the end of the day, the best thing for me to do is turn off Wi-Fi and Bluetooth, then use the shortcut to put the device to sleep, and finally close the lid before putting the MBA in my backpack.