diff --git a/lib/src/child-writer/index.js b/lib/src/child-writer/index.js index f53e6aa3..d503053d 100644 --- a/lib/src/child-writer/index.js +++ b/lib/src/child-writer/index.js @@ -117,13 +117,20 @@ exports.write = (image, drive, options) => { child.stderr.on('data', (data) => { emitter.emit('error', new Error(data.toString())); + + // This function causes the `close` event to be emitted + child.kill(); + }); child.on('error', (error) => { + ipc.server.stop(); emitter.emit('error', error); }); child.on('close', (code) => { + ipc.server.stop(); + if (code === EXIT_CODES.CANCELLED) { return emitter.emit('done', { cancelled: true