I've been based in EWR for 18 years. There is customs available 24/7. It is minimal after a certain time but it is there. One of the reasons is to accommodate diverts. And flights that are ridiculously late. I pulled in at 3am one time and customs was there.
I am not commenting on what should or should not have happened on this flight, I'm just stating a fact