Diminishing marginal returns is something that is always present in any kind of productive process. For all other conditions remaining constant the increase in one factor of production will not continue to increase production by the same extent and the decrease in the change is known as diminishing marginal returns.
The increasing marginal cost also cannot be looked at in isolation. It has to be looked at in terms of what the difference between marginal revenue and the marginal cost is. The difference can be allowed to decrease till marginal cost is equal to marginal revenue. Production should not be increased beyond the point when the marginal cost and marginal revenue is equal as that will not increase the total returns.
So a firm can produce goods even if there is diminishing marginal returns and the marginal cost is rising based on and because of what the value of the difference between the marginal revenue and the marginal cost is.
The reason for this is that a firm should produce the quantity of goods where the marginal cost is equal to the marginal revenue that the firm gets for selling the next unit of product. This point generally comes at a point where the marginal cost curve is upward sloping (where MC is rising).
If a firm stops producing at the quantity just before diminishing marginal returns sets in, it will not make as much money as is possible. The maximum possible profit comes when the firm produces at the MR = MC quantity. So, if a firm stops producing simply because MC is rising, they will not make the highest possible profit.