Fix random slowness when closing image