Make exit cleanup process more generic