Support custom wait and stop functions

Hello,

At (very rare) times, we may want to further customize the wait or stop logic with some esoteric logic. This would allow users to do so.