Merge cleanup functions of all platforms to a single one