If you are in the United States and you are talking about "open-end" investment companies, then there are two things that could stop this.
The first one is that some funds place contractual restrictions on how often you are allowed to trade, they may waive that or partially waive it if you move the money inside the fund family. They may also restrict how much you could sell at any one time. Most, if not all mutual funds can require you to accept a basket of securities in lieu of cash should you try and sell too much.
The second one is more pragmatic. Most mutual funds, though there are exceptions, only value their portfolios one time per day. It is usually one minute after the close of trading. So, imagine you decide to sell at 4:00 pm EST 100 shares of ABC Fund. The order will not be processed until the next valuation time which would be tomorrow after the close of business.
If you decided at 10:00 am to buy 100 shares and sell 100 shares at 11:00 am, both orders would process, but at the price one minute after close not the prices at 10 and 11 am. You get one trade per day and it happens when the day is over, with a handful of exceptions. They may all be institutional funds as well.
In other words, your buy and sell orders have to be made before you can know the prices that will be used to settle the trade. If at 10 am the price is $100 dollars and you sell but the market closes at $50, you will be paid 100x$50 for $5000 and not the $10,000 you thought you were getting.
The law put that mechanism in place to prevent speculation.
As far as I know, that rule is uniquely American. I would presume that other nations use other rules.