Added 'close hook (fixes #108).