Clean up properly when dismissing the modal by clicking on the backdrop