First I'll do this assuming that there is no immediate withdrawal or unscheduled partial-term second withdrawal since we can account for this by hand adding a few terms and altering the deposit amount afterward.
Here's a quick run through a specific example. Say you deposited \$100,000, and were going to withdrawal \$5000 after every interest period, and you received 6% interest each period. At each stage, the current money is increased by the interest (multiply by $1.06$), and the withdrawal is subtracted, so your account would go like this:
$ \begin{array}{rl} \text{Deposit, withdrawal 0:}&100000 \\ \text{After withdrawal 1:}&(100000)(1.06) - 5000 \\ \text{After withdrawal 2:}&(100000)(1.06)^2 - (5000)(1.06) - 5000\\ \text{After withdrawal 3:}&(100000)(1.06)^3 - (5000)(1.06)^2 - (5000)(1.06) - 5000\\ &\vdots \\ \text{After withdrawal n:}&(100000)(1.06)^n - (5000)(1.06)^{n-1} - \dots - (5000)(1.06)^0\\ =&(100000)(1.06)^n - (5000)\sum_{k=0}^{n-1}(1.06)^k \\ \end{array} $
This should suggest what happens in general, and in fact we can just replace those numbers with variables and see that the same thing happens. Let $d$ be the initial deposit, $r$ be the interest rate for each year-long-term as a decimal like 1.06 for 6%, and let $w$ be the withdrawal amount each term:
$ \begin{array}{rl} \text{Deposit, withdrawal 0:}&d \\ \text{After withdrawal 1:}&dr - w \\ \text{After withdrawal 2:}&dr^2 - wr - w\\ \text{After withdrawal 3:}&dr^3 - wr^2 - wr - w\\ &\vdots \\ \text{After withdrawal n:}&dr^n - wr^{n-1} - \dots - wr^0\\ =&dr^n - w\sum_{k=0}^{n-1}r^k \\ \end{array} $
We can evaluate that sum since its a geometric series, so after $n$ years and withdrawals, the amount of money is:
$ dr^n - w(\frac{r^n - 1}{r - 1}) $
Now, in your weird not-the-same-frequency withdrawal case, we need to stick two extra terms on the front. The first two withdrawals can be interpreted as changing the initial deposit for this term we just came up with.
The first withdrawal makes our deposit $d-w$ instead of $d$. The $m$ days of interest correspond to letting our $d-w$ accrue $r^{(m/365)}$, so this changes the deposit to $(d-w) r^{(m/365)}$. The second withdrawal at this point changes it to $(d-w) r^{(m/365)} - w$. So we'll substitute this in for $d$ where it occurred in the earlier equation.
If you've been skipping all of this so far, here's the equation. Plug in the variables, set it to $0$, and solve for $w$.
$ ((d-w) r^{(m/365)} - w)r^n - w(\frac{r^n - 1}{r - 1}) $
At this point we go to a computer algebra system and ask it to simply this expression or solve it for $w$ because we're lazy (but not so lazy as to go find out if the CAS or Excel had a built in function for doing all of this for us).
Edit, actually did the above, and it pops out:
$ w = \frac{d (r-1) r^{\frac{m}{365}+n}}{-r^{\frac{m}{365}+n}+r^{\frac{m}{365}+n+1}+r^{n+1}-1} $
In the particular case of your example in the OP, we want to solve for $w$ in
$ ((100000-w) (1.03)^{(150/365)} - w)(1.03)^4 - w(\frac{(1.03)^4 - 1}{(1.03) - 1})=0 $
which by the above means we want
$ \frac{100000 (1.03-1) 1.03^{\frac{150}{365}+4}}{-1.03^{\frac{150}{365}+4}+1.03^{\frac{150}{365}+4+1}+1.03^{4+1}-1} $
which gives $w = 17667.39411...$. (here is a link to wolframalpha for evaluating it http://bit.ly/lof47Q )
Note I used $n=4$ years here. In your example you seem to have only gone $4$ terms despite saying 150 days plus five years. If you use $n=5$ you get $15355.50$.