Fix crash when closing the viewer when no overlay has been added.