How to make an Application.quit on trigger?

I want to make it so that when my character touches the enemy’s collider, (and in the case, it would be a sphere collider,) It automatically closes the game. So far, this is what I have an it will not work. The most It did was freeze the game for a second, then resumed playing. I have the code on my Main Camera, so it will happen with all of the enemies.

function OnControllerColliderHit(hit : ControllerColliderHit)
{
    if (hit.collider.name == "Sphere Collider")
    {
        Application.Quit();
    }
}

What am i doing wrong?

Why are you trying to do this? It would be interpreted as a crash by the player and probably be rejected from the app store, if that was where you were trying to go with it.

Quit is ignored in the editor or the web player.

You need to play it in a build. For example PC and Mac Standalone :