[MAINT] Fix graphics memory leaks.

As the title says.