JS: wait final event