Script error when closing modal before it's loaded

Story: https://reciprocitylabs.atlassian.net/browse/CORE-39