Repository: flutter
Issue: [tool_crash] tool crashes running windows desktop on exit
Labels: c: crash,tool,P2,team-tool,triaged-tool

## Command
```
flutter run -d windows -v -t .\lib\src\generator_2.dart
```

## Steps to Reproduce
Run windows desktop application, this happens occasionally during a quit. The kernel files might still be in use, so this deletion needs to be either delayed until app termination or allowed to fail

## Logs
FileSystemException: Deletion failed, OS Error: The process cannot access the file because it is being used by another process.
, errno = 32
```
#0      _Directory._deleteSync (dart:io/directory_impl.dart:201:7)
#1      FileSystemEntity.deleteSync (dart:io/file_system_entity.dart:458:47)
#2      ForwardingFileSystemEntity.deleteSync (package:file/src/forwarding/forwarding_file_system_entity.dart:72:16)
#3      ResidentRunner.preExit (package:flutter_tools/src/resident_runner.dart:1264:25)
#4      HotRunner.preExit (package:flutter_tools/src/run_hot.dart:1152:17)
<asynchronous suspension>
#5      ResidentRunner.exit (package:flutter_tools/src/resident_runner.dart:947:11)
<asynchronous suspension>
#6      TerminalHandler._commonTerminalInputHandler (package:flutter_tools/src/resident_runner.dart:1500:30)
#7      TerminalHandler.processTerminalInput (package:flutter_tools/src/resident_runner.dart:1584:13)
#8      _rootRunUnary (dart:async/zone.dart:1198:47)
#9      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#10     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
#11     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
#12     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:285:7)
#13     _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:385:25)
#14     _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:250:5)
#15     _AsBroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:484:11)
#16     _rootRunUnary (dart:async/zone.dart:1198:47)
#17     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#18     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
#19     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
#20     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:285:7)
#21     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:69:11)
#22     _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
```
```
[✓] Flutter (Channel unknown, 1.20.0-8.0.pre.57, on Microsoft Windows [Version 10.0.18363.900], locale en-US)
    • Flutter version 1.20.0-8.0.pre.57 at C:\Users\Jonah\flutter
    • Framework revision 8bd2e6585b (7 hours ago), 2020-07-11 12:15:19 -0700
    • Engine revision 9b3e3410f0
    • Dart version 2.9.0 (build 2.9.0-21.0.dev 06cb010247)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at C:\Users\Jonah\AppData\Local\Android\sdk
    • Platform android-29, build-tools 29.0.3
    • ANDROID_HOME = C:\Users\Jonah\AppData\Local\Android\sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.5.4)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.5.30011.22
    • Windows 10 SDK version 10.0.18362.0

[!] Android Studio (version 3.6)
    • Android Studio at C:\Program Files\Android\Android Studio
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[✓] VS Code (version 1.47.0)
    • VS Code at C:\Users\Jonah\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.12.2

[✓] Connected device (4 available)
    • Windows (desktop) • windows    • windows-x64    • Microsoft Windows [Version 10.0.18363.900]
    • Web Server (web)  • web-server • web-javascript • Flutter Tools
    • Chrome (web)      • chrome     • web-javascript • Google Chrome 83.0.4103.116
    • Edge (web)        • edge       • web-javascript • Microsoft Edge 83.0.478.58

! Doctor found issues in 1 category.

```

## Flutter Application Metadata
**Type**: app
**Version**: 1.0.0+1
**Material**: false
**Android X**: false
**Module**: false
**Plugin**: false
**Android package**: null
**iOS bundle identifier**: null
**Creation channel**: master
**Creation framework version**: 8b9935a5a8857c3146fedf33d744f8b31b35540a