Listen to 'close' event instead of 'finish'.