Custom HTTP500 causes issues with trailing url slash

If I create a 500.html page in the templates folder this is correctly displayed when http 500 errors are generated.
In a development environment with DEBUG=True any url that is requested will automatically have a slash appended e.g.

https://domain.com/myapp/page

becomes

https://domain.com/myapp/page/

If DEBUG=False then this does not happen and so any url without a trailing slash fails.

However
If I don’t have a 500.html file in the templates folder the trailing slash gets added?!

I have tried adding APPEND_SLASH = True to settings.py but this has no effect.

I would welcome any thoughts.

Many thanks
Paul