Close an issue if its merged into a branch that is merged into master?

Say I have an issue branch 1-first-issue. I work on this and realize another issue that I work on the branch 2-new-issue, a “child” of 1-first-issue. I work on 2-new-issue and merge it into 1-first-issue, then continue to work until I merge 1-first-issue into master.

If I do this, issue 2 does not get automatically closed. Is this the desired behavior, and is there any way to work around this to close both issue 1 and 2 when they are merged into master?