As transitionend event is flaky, support it with a timeout.

This is a dirty patch that would not work in all cases (f.ex. when
animating in and out too fast), but should at least not leave stuck items.