cleanup function emitting