cleanup write_handlers properly on stop