make stdout end event also resolve the promise