correctly cleanup when failing to quit