How to make the application exit when the player collides with portal_04 (this script is also on the coins being collected.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CoinPuckup : MonoBehaviour {
    
    public GameObject coin;
    public static int coinsCollected;
    public GameObject Portal_04;
    private bool SetActive;
    void Start()
    {
        if (coinsCollected == 0)
        {
            Portal_04.SetActive(false);
        }

        if (coinsCollected == 3)
        {
            Portal_04.SetActive(true);
        }
    }

    void OnTriggerEnter(Collider Other)
    {
        //Destroy(coin)
        coin.SetActive(false);
        coinsCollected = (coinsCollected + 1);

        if (Other.gameObject.CompareTag("FPSController"))
        {
            Application.Quit;
        }
        
    }
}

The script is telling me that the “application.quit” is not valid in this context, is there anyway to solve this

You cannot exit the application in any collision trigger events, or in events in general i think. Set a bool flag that you want to quit, and in your Update() check for the flag and Quit from there, also it is mor clean to not quit or branch to other scenes etc. from events.

Try

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;

 public class CoinPuckup : MonoBehaviour {
 
 public GameObject coin;
 public static int coinsCollected;
 public GameObject Portal_04;
 private bool SetActive;
 private bool quitapp;

 void Start()
 {
     quitapp = false;
     if (coinsCollected == 0)
     {
         Portal_04.SetActive(false);
     }

     if (coinsCollected == 3)
     {
         Portal_04.SetActive(true);
     }
 }

 void OnTriggerEnter(Collider Other)
 {
     //Destroy(coin)
     coin.SetActive(false);
     coinsCollected = (coinsCollected + 1);

     if (Other.gameObject.CompareTag("FPSController"))
     {
         quitapp = true;
     }
     
 }
void update()
{
  if (quitapp)
{
    Application.Quit;
 }
}

}