lib/core: checks if pid file exists before attempting to delete