Fix a bug where the mouseend listener was never getting unregistered