Fix segfault when releasing device wrapper within a platform