I think that depends on your operating system and also on your application
If you are using spring boot you could hit the /shutdown endpoint (more info here). Or your app could have a custom shutdown endpoint of it’s own.
If using linux you could use ps -ef | grep MyMainClass to find the process id (pid) and then kill the pid
On windows there’s less detail given for each process so you end up picking a java.exe task in Task Manager and killing it, you might use the memory & cpu usage as a guide if there’s more than one java.exe process.