Make wait() return a promise rejected with a TypeError once close() is called