flying: Fix bug causing hang on abnormal exit