Daemon (Service)
Daemon oder Windows System Service
Daemon oder auch Service Routinen sind mit Free Pascal siehe  wiki.freepascal.org/Daemons_and_Services  leicht zu realisieren, hier ein kleines Beispiel inklusive EventLog-Ausgabe.
Eine Variante in der FreeOnTerminate des Threads auf true gesetzt ist, wodurch im Daemon.Stop einfach mit Terminate das beenden des Threads eingeleitet werden kann und mit WaitFor auf das Ende gewartet werden kann. 

 thedaemon.lpr 
Ausgabe:
> thedaemon.exe --installthedaemon [2016-12-01 19:31:02.891 Debug] DaemonMapper.Createthedaemon [2016-12-01 19:31:02.891 Debug] DaemonMapper.Createtedthedaemon [2016-12-01 19:31:02.891 Debug] DaemonMapper.Installthedaemon [2016-12-01 19:31:02.907 Debug] Daemon.installed: true> net start theDaemonthedaemon [2016-12-01 19:31:05.360 Debug] DaemonMapper.Createthedaemon [2016-12-01 19:31:05.360 Debug] DaemonMapper.Createtedthedaemon [2016-12-01 19:31:05.360 Debug] DaemonMapper.Runthedaemon [2016-12-01 19:31:05.360 Info] Daemon TheDaemon current status: Start Pendingthedaemon [2016-12-01 19:31:05.360 Debug] Daemon.Start: truethedaemon [2016-12-01 19:31:05.360 Info] Daemon TheDaemon current status: Runningthedaemon [2016-12-01 19:31:05.360 Debug] Daemon.Execute: falsethedaemon [2016-12-01 19:31:05.360 Debug] Thread.Executethedaemon [2016-12-01 19:31:06.376 Debug] Thread.Loop Tick :1thedaemon [2016-12-01 19:31:07.379 Debug] Thread.Loop Tick :2thedaemon [2016-12-01 19:31:08.382 Debug] Thread.Loop Tick :3> net pause theDaemonthedaemon [2016-12-01 19:31:08.820 Info] Daemon TheDaemon current status: Pause Pendingthedaemon [2016-12-01 19:31:08.820 Debug] Daemon.Pause: truethedaemon [2016-12-01 19:31:08.820 Info] Daemon TheDaemon current status: Paused> net continue theDaemonthedaemon [2016-12-01 19:31:12.655 Info] Daemon TheDaemon current status: Continue Pendingthedaemon [2016-12-01 19:31:12.655 Debug] Daemon.Continue: truetheDaemon [2016-12-01 19:31:12.655 Info] Daemon TheDaemon current status: RunningtheDaemon [2016-12-01 19:31:13.224 Debug] Thread.Loop Tick :4theDaemon [2016-12-01 19:31:14.239 Debug] Thread.Loop Tick :5theDaemon [2016-12-01 19:31:15.255 Debug] Thread.Loop Tick :6theDaemon [2016-12-01 19:31:16.256 Debug] Thread.Loop Tick :7> net stop theDaemontheDaemon [2016-12-01 19:31:16.725 Info] Daemon TheDaemon current status: Stop PendingtheDaemon [2016-12-01 19:31:16.725 Debug] Daemon.Stop: truethedaemon [2016-12-01 19:31:17.272 Debug] Thread.Loop Tick :8thedaemon [2016-12-01 19:31:17.272 Debug] Thread.LoopStoppedthedaemon [2016-12-01 19:31:17.272 Debug] Thread.DestroytheDaemon [2016-12-01 19:31:17.272 Info] Daemon TheDaemon current status: Stopped> thedaemon.exe --uninstalltheDaemon [2016-12-01 19:31:20.198 Debug] DaemonMapper.CreatetheDaemon [2016-12-01 19:31:20.198 Debug] DeamonMapper.CreatetedtheDaemon [2016-12-01 19:31:20.214 Debug] DeamonMapper.UninstalltheDaemon [2016-12-01 19:31:20.214 Debug] Daemon.Uninstall: true