Switching docs would set up event listeners on Ace without tearing down any old listeners, which could lead to a memory leak. This tears down old listeners when detaching from the "old" doc