Fix Issues #103 - Shouldn't call sync.end() when there is an error