Change destruction order - fixes a shutdown crash discovered with mesa