Hack to emit end on close
Hack to emit end on close