This is going to be OS dependant. I don't know how to accomplish this under windows without using a service, in *nix you'll be looking a variety of options. Suffice it to say, you're going to be depending on the tools provided by the OS to do background processes.
Daemon threads are related to VM shutdown only in that they do not prevent it. In other words, a VM will exit even if there are threads set daemon currently running, where normally it would not if a non-daemon
thread was alive. When the VM shuts down, the threads go as well, daemon or otherwise.