Added try/finally block to set using_paste_magics