Yeah I would not want to wait til midnight to spray. I would just do it when convenient for me (middle of the day most likely) and turn off the lights for a couple hours and do the spraying and let the plants dry up before turning the lights back on. The lights going off for a couple hours won’t be a problem, even in flowering.
Whether spraying with lights on is harmful or not is dependent on many things, mostly what you are spraying and the intensity of the light. Oil based sprays like Neem oil will mess up your plants very bad if sprayed with lights on, like might as well throw the plants away bad. Other things can be safe to spray but hard to know what is safe and not safe so I usually only spray with lights off, with the exception of some products that say safe to spray with lights on, like the Optic Foliar products.
When I use Captain Deadbug on outdoor plants, I just wait for dusk and do the spraying then.