You can simplify it using:

unlink_if_exists("{$g['vardb_path']}/captiveportaldn.rules");