Fix error when closing gallery #105