cleanup on next tick to let any other handlers work first