When I send
G1 E5, the extruder motor rotates, but does not stop. It keeps rotating until I restart the system. I am using a Ramps 1.4 board and OctoPrint.
If the printer is in absolute positioning mode (which is used almost exclusively), then the extruder will either wind back or wind forward to the last 5mm point. Effectively, the firmware treats the extruder like any other axis, and you can set the origin whenever and wherever you like (it doesn't have to be the home position). Use G92 to reset the extruder position as follows:
G92 E0 ; Set the extruder position to 0 (origin) G1 E5 ; Extrude 5mm of filament G92 E0 ; Set the extruder position to 0 again
This is the usual way to purge filament in the slicer's start and end code. Note that you cannot rely on the current position being zero.