actually, I didn't think too far ahead on this because I almost exclusively use single quotes, but we also need to take care of the double quotes too, so let's make this a little more intuitive with arrays that can be easily modified later to add more rules if discovered.
First let's find what needs to be fixed and find the escaped quotes, first the single, then the double quotes.
$search = array('\\\'', '\"');
Then let's define how we want to replace them, in the same order we found them.
$replace = array('\'', '"');
Now we apply it against $css, simply add the 3 lines just above the fwrite line.
$search = array('\\\'', '\"'); //find escaped quotes
$replace = array('\'', '"'); //unescaped replacements
$css = str_replace($search, $replace, $css); //apply replacements
fwrite($fh, $css); //write to file