how do you use.Application:Quit() ?

I tried to run it from a c# script but get an (!)

UnityEngine.Application:Quit()
FaceAPIBehavior:ReadCallback(IAsyncResult) (at Assets\Maynards\Scripts\FaceAPIBehavior.cs:170)
System.Net.Sockets.SocketAsyncResult:Complete()
System.Net.Sockets.Worker:Receive()

What exactly is the issue? The app continues to run?

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
void Update() {
if (Input.GetKey("escape"))
Application.Quit();

}
}

Do that, export your app, press space… it should work

you can do that aswell:

if(GUI.Button(rect,"quit")){
Application.Quit();
}

press the button and it closes the app

Yes that works but I need to do it with out hitting a button or key. I’m sending a command via tcp/ip and I just need a line of code to exit.

Try to make sure you close the socket connection and do some cleanup before calling Application.Quit().

I can’t be sure but it looks like you are calling Application.Quit() from a worker thread, calling unity functions from other threads simply doesn’t work.

ahhh, ill just set a flag then, cool thx!