Added some pre-quit cleanup.