Correct resource cleanup order such that ImGUI doesn't complain on GCC when closing program (MSVC didn't care).