If you stick a depot at the end of a track, with the intention of capturing all trains that go on that track, you'll find that they don't stop inside, but keep popping out, unless you manually stop them while inside, or click their ‘send to depot’ button. Even if you put a one-way signal as close to the entrance as possible, trains will still pop their heads out, temporarily blocking other trains coming in.
But you can keep them in if you can make them ‘see’ a pre-exit signal that is already on red. An easy way to create such a signal is to create a loop that touches the incoming track. There must be no signals between that contact and the depot. Now put a one-way pre-combo anywhere on the loop, but not on the incoming track. As soon as a train passes, it triggers the pre-combo to red – but it remains red because it can see itself.
You should also make sure that incoming trains can't take the loop, e.g. by putting the points backwards. Plus, if the dead-end depot is a branch of the mainline, put a depot on the mainline at the junction to discourage trains from wandering into the dead end unscheduled.
Create a dead-end depot with the following steps:
Create a single-track branch off the main track.
Add a depot by the branch so that trains will prefer it over the real dead-end depot if they happen to need servicing while passing.
Create a tight loop at the end of the track and put a pre-combo signal on it.
Attach another depot to the end of the track.
When a train goes into the depot at the end, it will trigger the pre-combo signal to go to red. Because it's in a loop, it will sustain itself on red, even after the train has disappeared into the depot. No train will be able to leave the depot because it is stuck behind a virtual pre-entry signal, which is always blocked by the real pre-combo outside.
Note that trains still have running costs while trapped in the depot, so stop them as soon as is convenient with a click on the depot's own ‘stop’ button.