Write a pidfile when run in the background