It’s always a good idea to disconnect at least 2 to 4 hours from any screen or electronics so you can give yourself ample time to wind down and relax before going to sleep
I generally would say half an hour before… That sets the mood, I got time to read or listen to a sleep meditation, an evening gratitude meditation or do some gentle yoga. Hope this works:)
I would say as soon as possible. But I find it OK about an hour before sleep. I make myself some tea, write in my notes, share my thoughts with it. And dim the lights in that time, so you already prepare your body to a relaxing state.