After print complete printer didn't turn off nozzle and bed heating

I would like to start with the fact that I am a very new and inexperienced 3d printer operator. just few weeks of experience.

I started a print which was going to take a fair amount of time and I had to leave it unattended overnight. When I woke up the first thing was to check the printer from the control tab in octoprint.

The job appeared to be finished but through the camera I can see that the nozzle was still on top of the print and the scariest thing was that the heated bed was on 60° and the nozzle was also on 195°. It was just sitting there no movements and not extruding just heating what was left of the filament.

In the Temperature tab of octoprint the target temperature was off but the actual temperature was 195° and 60° as I mentioned

In the connection box I could see that the printer was disconnected

I hit the emergency stop button to cancel the job

After that I started another print and on purpose disconnected the USB cable and the printer did the same thing just stopped in place with heating still on which is a huge fire hazard.

This leads me to believe that there was a communication error and the print did not complete to the end even though it looks finished.

Does anyone have suggestions how can I setup unattended prints without worrying that I will burn the place down?

In most slicers, when you configure it with your printer profile, there is a "start gcode" and an "end gcode" in the profile. The "end gcode" will normally contain commands to turn off the nozzle and the bed, move the nozzle away from the print, etc.

OctoPrint can also provide GCODE Scripts. I've always used the "end gcode" from the slicer.

Please give us some details. What printer do you have? What slicer are you using? There was a template when you started your post but you deleted it. We could really use the information that is provided when you fill out the template.

If the printer disconnects from OctoPrint, there is nothing that OctoPrint can do unfortunately after that point - it needs to be connected to the printer to tell it to turn off the heaters & move out of the way, but a communication error prevents this from happening.