Let's just summarise:
Your Solution has two Projects PA and PB, both of which are executable.
In the PB code, you want to know if the user started PA or PB so that a "close" request in PB can either close the app or just the forms etc. from PB.
There is no direct way to tell that. But ... you could read the
Environment.CommandLine Property (System) | Microsoft Docs[
^] which would tell you which EXE file was started.
However, generally speaking, you shouldn't use Application.Exit directly at all, just close the form and lets it's parents handle Form.Closed to close themselves as needed. When the main (first or startup) form closes, the application will close automatically.