From Flushing take the subway to WTC. From WTC take PATH to Newark Penn.. I don't know the schedule from Newark Penn to EWR, so you should look into it, or grab a cab if they are around, or Uber it.
PATH runs every 30 mins after midnight and takes 25 mins or so to get into Newark Penn.