What happens to a detective in Scotland Yard who cannot move any further?
From the rules here

What if a detective is unable to move any more?
the game goes on and the rest of the detectives try to catch Mister X.

The rules also say.

The game is over if the detectives are no longer able to move. This
situation is reached at the latest at the 22nd move, but can be
reached earlier if detective are left with ticket they cannot use (bus
or underground). They are immobilised at the last point moved to.

And from another source here

If a detective no longer has any tickets or can't move from his
current station with the tickets he has left, he has to sit out.

I've not found anything about removing the piece from the board so rules about not having a space occupied by more than one figure would still apply.  In general when playing a board games it's better to assume that if the rules don't says something happens its probably doesn't. If a piece was supposed to be removed from the board its likely this would be stated.
There is a previous boardgames SE question here &quot;Can Mr. X move into or through a detective occupied field?&quot; It is argued that they would lose automatically and is the accepted answer.
Contrary to that, there is this thread on BGG which has argument that as a player not enter an occupied space that this also applies to Mr X. and it would be impossible for them to do.