This function finishes recording if a macro is being recorded. If the optional parameter
cancel is given and non-zero, then macro recording is aborted. Otherwise, the recorded macro is saved as specified by the parameters to the corresponding
macro_record function.