query.each now emits end when finished