make sure closing window during animations doesnt cause a segfault; print an error message instead