write a pid file on startup, cleanup on shutdown.