exit enhancement

with #1038 closes #870