added optional cleanup method to run after finishing with return value from handlers