I had this happen to me on and on with compose on desktop. You close the window and the java process continues. You have 6 processes everytime you look in task manager. You have to forcefully kill things on application end, nomater what they are, ktor servers, sockets, anything you see :)
I vaguely remember "System.exit(0)" not working or not being enough and putting this hook in in some components and cleaning up with it:
Runtime.getRuntime().addShutdownHook(...........)