Add option to end polling in callback