non-constant coefficient Differential Equation with Dirac delta (unsure how to properly write the solution) $\zeta$ is a constant, $g(M) < M$, $g^{-1}(\zeta) > 0$, and the equation is:
$$ a'(M) - a(M)\frac{g'(M)}{M-g(M)} + \frac{\delta_{g^{-1}(\zeta)}(M)}{M-g(M)} = 0 $$
Things can be left in terms of $g(M)$ and $g'(M)$ and the goal is to calculate $a(M)$ (by integrating from $0$ to $M$)
The reason for solving this equation is to get a solution for $a(M)$ in the following equation
$$
\partial_M{\Large[}a(M)(x-g(M)) + 1_{M \geq g^{-1}(\zeta)}(M){\Large]}_{x=M} = 0. 
$$ 
So I expanded the derivative and used the identity
$$
\partial_M1_{M \geq g^{-1}(\zeta)}(M) = \delta_{g^{-1}(\zeta)}(M)
$$ 
in order to get to the above differential equation.

The correct answer is: 
$$a(M) = a(0)*e^{\int_0^M\frac{g'(y)}{y-g(y)}dy} -\frac{e^{\int_{g^{-1}(\zeta)}^M\frac{g'(r)}{r-g(r)}dr}}{g^{-1}(\zeta)-\zeta}*1_{M \geq g^{-1}(\zeta)}$$

This is my work:
The homogeneous equation 
$$
a'(M) - a(M)\frac{g'(M)}{M-g(M)}  = 0 
$$ 
has solution: $$a(0)*e^{\int_0^M\frac{g'(y)}{y-g(y)}dy}$$ which I can easily calculate using the integrating factor. 
Now for when I am solving it with the dirac delta included, I am trying to solve it as an equation in the form: $y' + p(t)y = q(t)$ (so it is a linear first order ODE as described here) 
The form of the general solution is then:  $$a(M) = a(0)*e^{\int_0^M\frac{g'(y)}{y-g(y)}dy} -e^{\int_0^M\frac{g'(y)}{y-g(y)}dy}  *\int_0^M\delta_{g^{-1}(\zeta)}(y) * e^{-\int_0^y\frac{g'(r)}{r-g(r)}dr}*\frac{1}{y-g(y)}dy$$
which I simplified by just bringing inside the exponential: 
$$a(M) = a(0)*e^{\int_0^M\frac{g'(y)}{y-g(y)}dy} -\int_0^M\delta_{g^{-1}(\zeta)}(y) * e^{\int_y^M\frac{g'(r)}{r-g(r)}dr}*\frac{1}{y-g(y)}dy$$
So now, using the formal relation
$$
\int_X f(y)\delta_x(y)\mathrm{d}y= f(x)
$$ 
from the Wikipedia entry on Dirac measure, I calculated the integral to be $$-\int_0^M\delta_{g^{-1}(\zeta)}(y) * e^{\int_y^M\frac{g'(r)}{r-g(r)}dr}*\frac{1}{y-g(y)}dy = -e^{\int_{g^{-1}(\zeta)}^M\frac{g'(r)}{r-g(r)}dr}*\frac{1}{g^{-1}(\zeta)-\zeta}$$
So my final answer is: 
$$a(M) = a(0)*e^{\int_0^M\frac{g'(y)}{y-g(y)}dy} -\frac{e^{\int_{g^{-1}(\zeta)}^M\frac{g'(r)}{r-g(r)}dr}}{g^{-1}(\zeta)-\zeta}$$
which is nearly the actual answer, but it is missing the indicator function in the second term. 
Anyone can point out where I went wrong? I think it might have to do with the initial equation that is being solved as well, so maybe that is why the indicator function reappears.
Thanks!
 A: Thanks to @quarague for helping get to this answer!
So the expressions: 
$$-\int_0^M\delta_{g^{-1}(\zeta)}(y) * \frac{e^{\int_y^M\frac{g'(r)}{r-g(r)}dr}}{y-g(y)}dy = \frac{-e^{\int_{g^{-1}(\zeta)}^M\frac{g'(r)}{r-g(r)}dr}}{g^{-1}(\zeta)-\zeta} = $$
are only valid if the dirac measure's fixed element ($g^{-1}(\zeta)$ in our case) is in the set the integral is done over, so in this case, $[0,M]$, and otherwise the integral will be $0$. So we need for $g^{-1}(\zeta) \in [0,M]$
So basically the expression can be written:
$$-\int_0^M\delta_{g^{-1}(\zeta)}(y) * \frac{e^{\int_y^M\frac{g'(r)}{r-g(r)}dr}}{y-g(y)}dy = 1_{0 \leq g^{-1}(\zeta) \leq M}(M)\frac{-e^{\int_{g^{-1}(\zeta)}^M\frac{g'(r)}{r-g(r)}dr}}{g^{-1}(\zeta)-\zeta} $$ and since we use the condition $g^{-1}(\zeta) > 0$, we can rewrite $1_{0 \leq g^{-1}(\zeta) \leq M}(M)$ as $1_{g^{-1}(\zeta) \leq M}(M)$, and therefore we have as final answer:
$$a(M) = a(0)*e^{\int_0^M\frac{g'(y)}{y-g(y)}dy} -\frac{e^{\int_{g^{-1}(\zeta)}^M\frac{g'(r)}{r-g(r)}dr}}{g^{-1}(\zeta)-\zeta}*1_{M \geq g^{-1}(\zeta)}(M)$$ 
