Fix ordering bug when deleting pidfile