Changing callback event trigger from 'end' to 'close'

Seemed to be causing a race condition. Triggering the callback on 'close' should ensure that all data has been collected.