unity crashes on exit

This seems to happen at random, and I’ve had it on both of my machines and the machines at my uni, so I’m pretty sure it’s not a problem with the machine (though I could be wrong).

Basically what happens is, when I exit unity, by clicking the x in the top corner or alt-f4, the editor just hangs indefinitely and task manager instantly reports it as not responding.

This has happened on windows xp, 7, 8 and 8.1, with unity 4.3 and every update since.

Anybody know of what could be causing this and/or possible fixes, it would be greatly appreciated.

kill the adb.exe process and then close UNITY.

As of 4.3.4f1 it still exists as a bug. Need to run taskkill /IM adb.exe /F
Seems to be a questions of the “WRONG” version of ADB.EXE from what I have read, but which is the “RIGHT” one?
This powershell script fixes it:

start-process "D:\Program Files (x86)\Unity\Editor\Unity.exe"

$unity = get-process unity

$adb = $NULL

do {

 $adb = get-process adb

 if($adb)
 {

     Stop-Process $adb.id

 }

  Start-Sleep -m 5000

  $unity = get-process Unity

} while( $unity -ne $NULL )

HOW TO RUN IT: Create a shortcut with this in it

powershell.exe -windowstyle hidden -File "D:\Program Files (x86)\Unity\unity.ps1"

Files here: FILES

(windows) open notepad, and paste this

(“Name” = your account name)

(Program Files (x86) can also be Program Files, depends on your hardware)

.

@echo off

cd C:\Users\“Name”\AppData\Local\Android\android-sdk\platform-tools

adb devices

cd C:\Program Files (x86)\Unity\Editor

start Unity.exe

Exit

I had a very similar problem which was resolved just by adding the location of ABD as a system path.
Tried the above script and realised that ADB wasn’t even running.

Once I added the location of ADB as a system path, I’m guessing Unity could then find and start/stop it itself so the crash on exit was resolved for me. I didn’t need to use the above script after that.

To add ADB to your system path:

  1. Open command prompt as admin
  2. Type: setx PATH “%PATH%;C:\Program Files\android-sdk-windows\platform-tools” (change location of ADB as required)

The above fixed the crash problem for me on Windows 8.1 and I also force DX11 to make Unity more stable on Windows 8.1.

I’m also not sure if Unity installs the Android dev tools because I already had those installed so if you can’t find ADB and have the same problem I would suggest installing the Android dev tools as per the below article then setting the system path to ADB.