Well, unfortunately it is not possible to do so. Note HTTP connection is sessionless, i.e. when a request is processed, the connection is closed. When a user opened a file, before next action happens, the server doesn't know if the user is still using the file or not. So, if the server locks the file, and if the user has closed the browser (or FileManager), the file could be locked forever or until session times out.
FileManager will prompt for overwriting if a file is changed by another user. Please be careful to test this feature. A much better solution is to make sure that everybody copies the file to another folder and edit it. After done, copy it back to the shared folder.