diff --git a/htmltidy.js b/htmltidy.js
index 6e501da..4c4b0bb 100644
--- a/htmltidy.js
+++ b/htmltidy.js
@@ -126,7 +126,7 @@ function tidy(text, opts, cb) {
worker.on('error', function (data) {
error+= data;
});
- worker.on('end', function (code) {
+ worker.on('close', function (code) {
cb(error, result);
});
worker.end(text);