same close behaviour as Node.js