Changed modal cleanup behaviour to only occur on successful submit