[Plugin] Fix wait routine (thx rlindner81)