If the console deems the PS4 too hot, the fan will stay on for 30 seconds to a minute to cool the system down before it shuts down. Once it shuts down, you should give it until it is no longer hot to the touch before using it again.
Let's Get It Fixed!
HomeX virtual experts will assess your issue (for free!) and can resolve simple problems.